What is the action_condition event handler?
The action_condition event handler is what allows for some steps in Cyclr to have a true/false output.
It essentially combines a Method with a Decision Step, allowing you to direct the transaction down either the True or False exit points. It is one of the few event handlers where returning false can be a valid value.
The action_condition can only run after a response is received. This is because of it’s true/false nature: when you return false, the cycle continues via the red (false) output of the step, and if you return true, your cycle continues via the green (true) output of the step.
When to use Action Condition
The Action Condition event handler is used when a method can be successful and return a response, but that response does not contain any useful data. Generally, the main instances where an action_condition is necessary, would be with any ‘List’ or ‘Search’ methods.
For instance, if you run a ‘List Contacts’ method, but have no contacts created, the request will return an empty ‘data’ array. In this situation, you may not want to continue the cycle. If the next step is supposed to use a piece of data from the response, you would get an error because the response’s data array is empty.
The action_condition offers a way to add conditions to the cycle so you can avoid these kind of errors and end the cycle or route it differently if the required data is not present in the response.
When scripting an action condition you can test it by writing your script in the script tab on the method level, pushing a new test release and running a cycle with the upgraded method.
You should then see the True/False outputs in your upgraded method when you use it in a Cycle, like this:
