WFActivityHandler - Global

The base class for all workflow activities.

As the base class for all workflow activities, this code always executes as part of an activity.

When developing your own workflow activities, create your script object by deriving from this class and overriding methods as necessary to get the functionality you want. Client code must override method onExecute() to perform meaningful activity processing.

WFActivityHandler - debug(String msg, String args)

Logs a debug message.

Table 1. Parameters
Name Type Description
msg String Message to send to the log.
args String String to send to the log
Table 2. Returns
TypeDescription
void

WFActivityHandler - debug(String msg, Array args)

Logs a debug message.

Table 3. Parameters
Name Type Description
msg String Message to send to the log.
args Array Array of values to send to the log
Table 4. Returns
TypeDescription
void

WFActivityHandler - generate(String activityId, String order,GlideDateTime startAtDspValue, Boolean noCreateFlag)

Handles pre-generation of tasks and approvals (and other objects as needed). Allows objects to be generated at the start of a workflow in a pending state and not requested until the workflow gets to the activity, thereby providing a preview of the work to be done in the future. To pre-generate objects, an activity's _generate() method is called. This method typically returns a pre-generation object that is saved in the workflow scratchpad. (For example, the object might be an array of approval ids that were generated.) When the activity runs onExecute it may request the pre-generation object and determine if the approvals have already been created in a pending state or if it needs to create the approvals in the onExecute method. Internal method _generate needs to be overridden and needs to return an object with information that it can retrieve later on when the activity's onExecute() method is called. The object must contain a duration property that contains the duration of the task(s) or approval(s) that were generated by the activity. See activity Generate for example usage.

Allows objects to be generated at the start of a workflow in a pending state and not requested until the workflow gets to the activity, thereby providing a preview of the work to be done in the future. To pre-generate objects, an activity's _generate() method is called. This method typically returns a pre-generation object that is saved in the workflow scratchpad. (For example, the object might be an array of approval ids that were generated.) When the activity runs onExecute it may request the pre-generation object and determine if the approvals have already been created in a pending state or if it needs to create the approvals in the onExecute method. Internal method _generate needs to be overridden and needs to return an object with information that it can retrieve later on when the activity's onExecute() method is called. The object must contain a duration property that contains the duration of the task(s) or approval(s) that were generated by the activity. See activity Generate for example usage.

Table 5. Parameters
Name Type Description
activityId String sys_id of this running activity (table wf_activity).
order String The order number associated with the task or approval.
startAtDspValue GlideDateTime The starting time for the task or approval
noCreateFlag Boolean
Table 6. Returns
TypeDescription
NumberThe duration property of the _generate return value is returned by this method..

WFActivityHandler - info(String msg, String args)

Logs an information message.

Table 7. Parameters
Name Type Description
msg String Message to send to the log.
args String String to send to the log.
Table 8. Returns
Type Description
void


    

WFActivityHandler - info(String msg, Array args)

Logs an information message.

Table 9. Parameters
Name Type Description
msg String Message to send to the log.
args Array Array of values to send to the log
Table 10. Returns
TypeDescription
void

WFActivityHandler - js(String str)

Evaluate activity variables in the script. Used to evaluate strings that contain el such as ${some script} or strings starting with javascript:. See almost any existing activity for example usage.

Used to evaluate strings that contain el such as ${some script} or strings starting with javascript:. See almost any existing activity for example usage.

Table 11. Parameters
Name Type Description
str String String that possibly contains embeded el.
Table 12. Returns
TypeDescription
StringThe evaluated string.

WFActivityHandler - onCancel( )

Event handler for cancel event. The base class for the activity script sets this activity to be cancelled. Derived classes (activities) can override this method if additional processing is required to cancel this activity. Activity Manual Approvals is an example of overriding this method to perform additional processing to cancel this activity.

The base class for the activity script sets this activity to be cancelled. Derived classes (activities) can override this method if additional processing is required to cancel this activity. Activity Manual Approvals is an example of overriding this method to perform additional processing to cancel this activity.

Table 13. Parameters
Name Type Description
None
Table 14. Returns
TypeDescription
void

WFActivityHandler - onExecute( )

Virtual method. Activity subclasses must override this method to perform work appropriate to the activity.

Table 15. Parameters
Name Type Description
None
Table 16. Returns
TypeDescription
void

WFActivityHandler - runScript(String script)

Enables activities to run a script contained in an activity variable of type script. Example activities that use this method include If, Wait for condition, and Approval - User.

Example activities that use this method include If, Wait for condition, and Approval - User.

Table 17. Parameters
Name Type Description
script String String containing valid Javascript.
Table 18. Returns
TypeDescription
variableIf the script set the workflow variable answer then this value is returned. If not, then the result of the script execution is returned.

WFActivityHandler - setActivityOutput( )

Sets the activity output property. See activity SOAP Message.

See activity SOAP Message.

Table 19. Parameters
Name Type Description
None
Table 20. Returns
TypeDescription
void

WFActivityHandler - setResultFailed(String reason)

Sets the activity result as failed with an optional reason string. See activity SOAP Message.

See Activity SOAP Message.

Table 21. Parameters
Name Type Description
reason String (Optional) Description of the reason this activity failed.
Table 22. Returns
TypeDescription
void

WFActivityHandler - setResultSucceeded( )

Sets the result of this activity as successful.

Table 23. Parameters
Name Type Description
None
Table 24. Returns
TypeDescription
void

WFActivityHandler - warn(String msg, String args)

Logs a warning message.

Table 25. Parameters
Name Type Description
msg String Message to send to the log.
args String String to send to the log
Table 26. Returns
TypeDescription
void

WFActivityHandler - warn(String msg, Array args)

Logs a warning message.

Table 27. Parameters
Name Type Description
msg String Message to send to the log.
args Array Array of values to send to the log
Table 28. Returns
TypeDescription
void