Chaining actions
A rule can run multiple actions, and sometimes an action may need to use the result of a previous action. This can be achieved by chaining actions.
It is only possible to chain actions within the same rule. If an action depends on a previous action's result, the previous action must be fired from the same rule, and must come before the action that depends on it.
Previous action results
Each action can return a result by using a return
statement to terminate the execute
method. This is useful if the action receives a reference from another system. Jadu Central will store whatever the action returns for use in later actions.
Supporting chaining
In order to support chaining, the custom action class should contain the following method:
/**
* Whether this action can use values from a previous action.
*
* @return bool
*/
public function allowsChaining()
{
return true;
}
This tells Jadu Central that this action can take in values returned from previous actions.
Any fields defined to be mapped by the action that have options
set to MAPPING_TYPE_CORE
will now have a checkbox underneath labelled Use a value from a previous action
. Each field that has this ticked can then be populated by the value returned from previous actions when the corresponding template is added to a rule.