The Calculate Control allows designers to add JavaScript code to a Page that is executed when the Page is initially loaded, and also whenever the value of any Field on the Page is altered.
This can be contrasted with the
JavaScript, where the configured code is only executed a single time upon Page load, but retains its state after that.
The Field isn't visible to the agent at all.
This Control is part of the Intermediate Control pack, and will only be available if your System has the appropriate licence.
Add a Calculate to the Page. The Code Description can be configured in the
Options tab of the Field Properties, and can be used to set a brief description of the functionality of the Calculate. Note that this description is not visible to the agent, as neither is the Field itself, but merely serves to clarify to a another User within the Designer the purpose of the Calculate at a glance.
To configure the code to be executed, use the
Code Editor in the Advanced Options tab.
Refer to the
Code Execution article for specific details as to JavaScript execution order and variable scope.
Due to the code within a Calculate being executed every time a Field's value is updated on the Page (except for when this Field is updated by the Calculate itself), particular care should be taken of how code is written in the Calculate. Use of conditional statements (if (...) {...} else {...}) can be used to control what code is executed and when.
If you need to limit how many times the Calculate runs, please see the "Run Once" article in the
Knowledge Base.
It is also possible to define variables or functions globally across an entire installation of Intelligent Agent by placing it within the
custom.js file. This is an advanced action with potentially dangerous outcomes if implemented improperly, please see
this Knowledge Base article for further information.