---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# WFActivityHandler - Global

# WFActivityHandler - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

The WFActivityHandler script include is 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) {#ariaid-title2}

Logs a debug message.
{#r_WFAH-debug_S_S__table_xdr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | String | String to send to the log |
[Table 1. Parameters]

{#r_WFAH-debug_S_S__table_xdr_nf5_4t} {#r_WFAH-debug_S_S__table_ydr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_WFAH-debug_S_S__table_ydr_nf5_4t}

## WFActivityHandler - debug(String msg, Array args) {#ariaid-title3}

Logs a debug message.
{#r_WFAH-debug_S_A__table_bv2_sh5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | Array | Array of values to send to the log |
[Table 3. Parameters]

{#r_WFAH-debug_S_A__table_bv2_sh5_4t} {#r_WFAH-debug_S_A__table_cv2_sh5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_WFAH-debug_S_A__table_cv2_sh5_4t}

## WFActivityHandler - generate(String activityId, String order,
GlideDateTime startAtDspValue, Boolean noCreateFlag) {#ariaid-title4}

Generates approvals and tasks before the activity runs for a preview of upcoming
work.
Enables generating objects at the start of a workflow in a pending
state. For related information, see [Generate workflow activity](https://www.servicenow.com/docs/access?context=r_Generate&version=xanadu&pubname=xanadu-build-workflows&ft:locale=en-US).
{#r_WFAH-generate_S_S_GDT_B__table_dv2_sh5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| activityId | String | Sys_id of this running activity. Located in the Workflow Activities \[wf_activity\] table. |
| order | String | The order number associated with the task or approval. |
| startAtDspValue | String | The starting time for the task or approval in [GlideDateTime](https://servicenow-prod.fluidtopics.net/tvAoVJXo8tw~UsFkybHP0g#c_GlideDateTimeAPI "The GlideDateTime class provides methods for performing operations on GlideDateTime objects.") format. |
| noCreateFlag | Boolean | Flag that indicates whether to skip creating an approval record. Valid values: * true: Do not create an approval record. * false: Create an approval record. {#r_WFAH-generate_S_S_GDT_B__ul_cbr_ds4_f4b} Default: True |
[Table 5. Parameters]

{#r_WFAH-generate_S_S_GDT_B__table_dv2_sh5_4t} {#r_WFAH-generate_S_S_GDT_B__table_ev2_sh5_4t__entry__2}

| Type | Description |
|-|-|
| Object | Pre-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. * The activity must create the approvals using the onExecute function. {#r_WFAH-generate_S_S_GDT_B__ul_u13_mdp_f4b} |
[Table 6. Returns]

{#r_WFAH-generate_S_S_GDT_B__table_ev2_sh5_4t}

## WFActivityHandler - info(String msg, String args) {#ariaid-title5}

Logs an information message.
{#r_WFAH-info_S_S__table_pdr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | String | String to send to the log. |
[Table 7. Parameters]

{#r_WFAH-info_S_S__table_pdr_nf5_4t} {#r_WFAH-info_S_S__table_qdr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_WFAH-info_S_S__table_qdr_nf5_4t}

## WFActivityHandler - info(String msg, Array args) {#ariaid-title6}

Logs an information message.
{#r_WFAH-info_S_A__table_rdr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | Array | Array of values to send to the log |
[Table 9. Parameters]

{#r_WFAH-info_S_A__table_rdr_nf5_4t} {#r_WFAH-info_S_A__table_qdr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 10. Returns]

{#r_WFAH-info_S_A__table_qdr_nf5_4t}

## WFActivityHandler - js(String str) {#ariaid-title7}

Evaluates 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.
{#r_WFAH-js_S__table_ndr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| str | String | String that possibly contains embeded el. |
[Table 11. Parameters]

{#r_WFAH-js_S__table_ndr_nf5_4t} {#r_WFAH-js_S__table_odr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| String | The evaluated string. |
[Table 12. Returns]

{#r_WFAH-js_S__table_odr_nf5_4t}

## WFActivityHandler - onCancel( ) {#ariaid-title8}

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.
{#r_WFAH-onCancel__table_pqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 13. Parameters]

{#r_WFAH-onCancel__table_pqd_1b5_4t} {#r_WFAH-onCancel__table_qqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 14. Returns]

{#r_WFAH-onCancel__table_qqd_1b5_4t}

## WFActivityHandler - onExecute( ) {#ariaid-title9}

Virtual method. Activity subclasses must override this method to perform work appropriate to the activity.
{#r_WFAH-onExecute__table_nqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 15. Parameters]

{#r_WFAH-onExecute__table_nqd_1b5_4t} {#r_WFAH-onExecute__table_oqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 16. Returns]

{#r_WFAH-onExecute__table_oqd_1b5_4t}

## WFActivityHandler - runScript(String script) {#ariaid-title10}

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.
{#r_WFAH-runScript_S__table_rqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| script | String | String containing valid Javascript. |
[Table 17. Parameters]

{#r_WFAH-runScript_S__table_rqd_1b5_4t} {#r_WFAH-runScript_S__table_sqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| variable | If the script set the workflow variable <var class="keyword varname">answer</var> then this value is returned. If not, then the result of the script execution is returned. |
[Table 18. Returns]

{#r_WFAH-runScript_S__table_sqd_1b5_4t}

## WFActivityHandler - setActivityOutput( ) {#ariaid-title11}

Sets the activity output property.
See activity SOAP Message.
{#r_WFAH-setActivityOutput__table_lqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 19. Parameters]

{#r_WFAH-setActivityOutput__table_lqd_1b5_4t} {#r_WFAH-setActivityOutput__table_mqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 20. Returns]

{#r_WFAH-setActivityOutput__table_mqd_1b5_4t}

## WFActivityHandler - setResultFailed(String reason) {#ariaid-title12}

Sets the activity result as failed with an optional reason string.
See Activity SOAP Message.
{#r_WFAH-setResultFailed_S__table_hqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| reason | String | (Optional) Description of the reason this activity failed. |
[Table 21. Parameters]

{#r_WFAH-setResultFailed_S__table_hqd_1b5_4t} {#r_WFAH-setResultFailed_S__table_iqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 22. Returns]

{#r_WFAH-setResultFailed_S__table_iqd_1b5_4t}

## WFActivityHandler - setResultSucceeded( ) {#ariaid-title13}

Sets the result of this activity as successful.
{#r_WFAH-setResultSucceeded__table_jqd_1b5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 23. Parameters]

{#r_WFAH-setResultSucceeded__table_jqd_1b5_4t} {#r_WFAH-setResultSucceeded__table_kqd_1b5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 24. Returns]

{#r_WFAH-setResultSucceeded__table_kqd_1b5_4t}

## WFActivityHandler - warn(String msg, String args) {#ariaid-title14}

Logs a warning message.
{#r_WFAH-warn_S_S__table_tdr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | String | String to send to the log |
[Table 25. Parameters]

{#r_WFAH-warn_S_S__table_tdr_nf5_4t} {#r_WFAH-warn_S_S__table_udr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 26. Returns]

{#r_WFAH-warn_S_S__table_udr_nf5_4t}

## WFActivityHandler - warn(String msg, Array args) {#ariaid-title15}

Logs a warning message.
{#r_WFAH-warn_S_A__table_vdr_nf5_4t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to send to the log. |
| args | Array | Array of values to send to the log |
[Table 27. Parameters]

{#r_WFAH-warn_S_A__table_vdr_nf5_4t} {#r_WFAH-warn_S_A__table_udr_nf5_4t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 28. Returns]

{#r_WFAH-warn_S_A__table_udr_nf5_4t}

