Availability and Requirements
The workflow manipulation API is available in the following MetaScript environments:
- Forms - Server-side MetaScript (and any scripts included in it)
- Forms - Global MetaScript (and any scripts included in it)
- MetaScript Actions (and any scripts included in it)
To use the API, the following line must appear in the script before any code that is using the API:
Workflow object
The workflow object is used for all API operations. The workflow object is a property of a Virtual Ticket object, which is what being presented to the user in a VT browser using forms. In the remainder of this API section, the workflow object will be referred to as simply "workflow".
Accessing the workflow of the Virtual Ticket object shown in current form
To access the workflow of the VT object that is shown in the current form, use this MetaScript code:
Accessing the workflow of other Virtual Ticket objects
To access the workflow of a VT object other than the one shown in the current form, first the VT object needs to be obtained. The workflow is then accessible via the "workflow" property.
Here is example code utilizing Database repository to obtain the VT object:
Modifying the objects and workflows
While the current object in the form is being edited by the user, any changes made by the script will be immediately visible to the user in the form, and these changes will be automatically saved when the user presses "Update" in their VT browser (or VT find).
Example of the code making changes to the object and the workflow:
In all other cases (e.g. in order to modify any other VT object, or the currently shown object outside the Edit mode of the form), your script must load and save the object, wrapping all operations in transaction: