Condition Extensions

A Condition Extension serves the same function as any single item in a Condition tree in a Target Group or other places where you build Conditions.

Therefore, it’s functionally the same as a Person Data Condition or any other. This means that you can build Condition trees where you combine “normal” Conditions with Extension Conditions. This is a nice way to build more advanced filters using data or logic that isn’t currently available in Agillic like ensuring that only one recipient with a particular email goes into a Flow, even when the email field itself is not unique.

Execution Method

The execution method for a Condition Extension must be called evaluate, assumed to return a boolean value, true if the recipient should be considered to match the condition and false otherwise. If the script does not return a value, returns something which is not a boolean or throws an exception, it’s treated as false, and the recipient does not match the condition.

//@id:"ConditionExtension"
//@type:"condition"
function evaluate(recipient,global,settings) {
   return true;
}

Arguments

The input arguments for Condition Extensions are:

  • recipient: provides access to the recipient (Person Data, One To Many Tables, Target Groups, and Event Achieving)
  • global: provides access to global data (Global Data and Global Data Tables)
  • settings: enables configurators to provide setting attributes from any condition editor UI, for each particular implementation of this extension.

See the Read and Write section for details on how to use these arguments.

Because of internal requirements of how we evaluate conditions, writing to a recipient (Person Data, One To Many Tables) during a Condition Extensions is not supported.

To optimize performance of your Condition Extension, we recommend you pre-load data fields which needs to be read during execution.

Parameters Function

The method is used to specify the fields present settings parameters. Values to those fields are inserted as a required sub-group Conditions for the Condition Extension.

If the method is not included or returns an empty list and no parameters can be configured in the UI.

Optimizations

In Extension Steps & Condition Extensions you can optimize the extension data-read time by declaring which Person Data fields, Target Groups, and One To Many tables you need access to during evaluation. These input values are defined with additional methods in your extension code.

Agillic will pre-load the specified data to optimize execution.

We strongly recommend that these pre-loading functions are used when possible. You can even use the same settings argument (if present in the extension type’s execution method) to define what entities need to be pre-loaded.

None of the methods are required, and if they are not declared in the script we treat it as an empty list of requirements. The methods are assumed to return a list of strings with the names of the relevant items to load.

If you want to read the Target Groups a recipient belongs to, it is mandatory to declare them in this pre-loading function, as the performance overhead would otherwise be too great. If you try to load a Target Group that you have not pre-loaded, the script will fail.

function getRequiredPersonData(settings) {
    return ["AGE","LASTNAME"];
}
 
function getRequiredOneToManyTables(settings) {
    return ["PURCHASE","COUPONS",settings["INPUT_OTM_1"]];
}

function getRequiredTargetGroups(settings) {
    return ["Gold customers","All recipients"];
}