1. Home
  2. Administrators
  3. Control
  4. JavaScript formula control to advance and undo transitions

JavaScript formula control to advance and undo transitions

The category manager control step allows us to set restrictions to control who and when can advance or roll back through any transition in a process.

Firstly, you can set which users can or can’t move forward/back through the transition.

At a more advanced level, it is also possible to specify a JavaScript formula that, based on its result, causes the control to take effect or not.

The formula must be designed to return a message or reason why the action is prevented from the user . If the formula does not return a message (it returns the empty message “”) it is understood that this control has no effect.

For example, if in a category of Invoices we want that from a certain amount only a supervisor can issue it (advance from creation to issue) we could put a control like:

This formula could have the following code:

if(< @Data:Total>> 3000 &&
<@Data:Supervisors> .indexOf(User.name())< 0)

return “This invoice can only be issued by a supervisor”

else

return ""

In this way, if the value of the “Total” field is greater than 3,000 and the name of the advancing user is not in the “Supervisors” user type field, the corresponding error message will be displayed . In any other case, returning an empty string overrides this check and the transition can be used by anyone.

Updated on 6 de November de 2023
Was this article helpful?

Related Articles