{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1122,"path":"api-reference/server-api-reference/c_WFACtivityHandlerAPI.md","title":"WFActivityHandler - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# WFActivityHandler- Global\n\nThe WFActivityHandler script include is the base class for all workflow activities.\n\nAs the base class for all workflow activities, this code always executes as part of an activity.\n\nWhen 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.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## WFActivityHandler - debug\\(String msg, String args\\)\n\nLogs a debug message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|String|String to send to the log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - debug\\(String msg, Array args\\)\n\nLogs a debug message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|Array|Array of values to send to the log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - generate\\(String activityId, String order, GlideDateTime startAtDspValue, Boolean noCreateFlag\\)\n\nGenerates approvals and tasks before the activity runs for a preview of upcoming work.\n\nEnables generating objects at the start of a workflow in a **pending** state. For related information, see [Generate workflow activity](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/build-workflows/r_Generate.md).\n\n<table id=\"table_dv2_sh5_4t\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nactivityId\n\n</td><td>\n\nString\n\n</td><td>\n\nSys\\_id of this running activity. Table: Workflow Activities \\[wf\\_activity\\]\n\n</td></tr><tr><td>\n\norder\n\n</td><td>\n\nString\n\n</td><td>\n\nOrder number associated with the task or approval.\n\n</td></tr><tr><td>\n\nstartAtDspValue\n\n</td><td>\n\nString\n\n</td><td>\n\nStarting time for the task or approval in [GlideDateTime](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideDateTimeAPI.md) format.\n\n</td></tr><tr><td>\n\nnoCreateFlag\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to skip creating an approval record.Valid values:\n\n-   true: Don't create an approval record.\n-   false: Create an approval record.\n\nDefault: true\n\n</td></tr></tbody>\n</table><table id=\"table_ev2_sh5_4t\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nPre-generation object saved in the workflow scratchpad. For example, the object might be an array of approval IDs. When the activity runs the onExecute function, it can request the pre-generation object to determine one of the following conditions:-   Approvals have already been created in a pending state.\n-   Activity must create the approvals using the onExecute function.\n\n</td></tr></tbody>\n</table>## WFActivityHandler - info\\(String msg, String args\\)\n\nLogs an information message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|String|String to send to the log.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - info\\(String msg, Array args\\)\n\nLogs an information message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|Array|Array of values to send to the log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - js\\(String str\\)\n\nEvaluates activity variables in the script.\n\nUsed to evaluate strings that contain el such as `${some script}` or strings starting with `javascript:`. See almost any existing activity for example usage.\n\n|Name|Type|Description|\n|----|----|-----------|\n|str|String|String that possibly contains embeded el.|\n\n|Type|Description|\n|----|-----------|\n|String|The evaluated string.|\n\n## WFActivityHandler - onCancel\\( \\)\n\nEvent handler for **cancel** event.\n\nThe 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - onExecute\\( \\)\n\nVirtual method. Activity subclasses must override this method to perform work appropriate to the activity.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - runScript\\(String script\\)\n\nEnables activities to run a script contained in an activity variable of type script.\n\nExample activities that use this method include If, **Wait for condition**, and **Approval - User**.\n\n|Name|Type|Description|\n|----|----|-----------|\n|script|String|String containing valid Javascript.|\n\n|Type|Description|\n|----|-----------|\n|variable|If the script set the workflow variable *answer* then this value is returned. If not, then the result of the script execution is returned.|\n\n## WFActivityHandler - setActivityOutput\\( \\)\n\nSets the activity output property.\n\nSee activity **SOAP Message**.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - setResultFailed\\(String reason\\)\n\nSets the activity result as failed with an optional reason string.\n\nSee Activity **SOAP Message**.\n\n|Name|Type|Description|\n|----|----|-----------|\n|reason|String|\\(Optional\\) Description of the reason this activity failed.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - setResultSucceeded\\( \\)\n\nSets the result of this activity as successful.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - warn\\(String msg, String args\\)\n\nLogs a warning message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|String|String to send to the log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WFActivityHandler - warn\\(String msg, Array args\\)\n\nLogs a warning message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Message to send to the log.|\n|args|Array|Array of values to send to the log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n"}}