---
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


---

# Workflow - Scoped

# Workflow - Scoped {#ariaid-title1}

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

The scoped Workflow API provides methods that can be used in an activity definition script.

There are no constructors for creating an instance of a scoped workflow object. Instead, use the global workflow object available in activity scripts. This workflow object is available in any script location inside a workflow.

## Scoped Workflow - debug(String message, Object args) {#ariaid-title2}

Adds a debug message to the log.
{#r_SWF-debug_S_O__table_q3h_rqz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to add to the log. |
| args | Object | Arguments to add to the message. |
[Table 1. Parameters]

{#r_SWF-debug_S_O__table_q3h_rqz_lt} {#r_SWF-debug_S_O__table_r3h_rqz_lt__entry__2}

| Type | Description |
|-|-|
| String | The message added to the log. |
[Table 2. Returns]

{#r_SWF-debug_S_O__table_r3h_rqz_lt}  

    var loggedMessage = workflow.debug("All is well");

## Scoped Workflow - error(String message, Object args) {#ariaid-title3}

Adds an error message to the log.
{#r_SWF-error_S_O__table_ttc_2rz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to add to the log. |
| args | Object | Arguments to add to the message. |
[Table 3. Parameters]

{#r_SWF-error_S_O__table_ttc_2rz_lt} {#r_SWF-error_S_O__table_utc_2rz_lt__entry__2}

| Type | Description |
|-|-|
| String | The logged message |
[Table 4. Returns]

{#r_SWF-error_S_O__table_utc_2rz_lt}  

    var loggedMessage = workflow.error("An error has occurred. ");

## Scoped Workflow - getVariable(String name) {#ariaid-title4}

Returns the specified variable's value.
{#r_SWF-getVariable_S__table_rsb_psz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The variable name |
[Table 5. Parameters]

{#r_SWF-getVariable_S__table_rsb_psz_lt} {#r_SWF-getVariable_S__table_ssb_psz_lt__entry__2}

| Type | Description |
|-|-|
| Object | The variable's value |
[Table 6. Returns]

{#r_SWF-getVariable_S__table_ssb_psz_lt}  

    var value = workflow.getVariable("task");

## Scoped Workflow - info(String message, Object args) {#ariaid-title5}

Adds an informational message to the log.
{#r_SWF-info_S_O__table_rz5_1qz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to add to the log. |
| args | Object | Arguments to add to the message. |
[Table 7. Parameters]

{#r_SWF-info_S_O__table_rz5_1qz_lt} {#r_SWF-info_S_O__table_sz5_1qz_lt__entry__2}

| Type | Description |
|-|-|
| String | The message that is logged. |
[Table 8. Returns]

{#r_SWF-info_S_O__table_sz5_1qz_lt}  

    var loggedMessage = workflow.info("All is well");

## Scoped Workflow - inputs {#ariaid-title6}

Object that contains the workflow variables.
This is not a method, but rather a way to reference the variables in a workflow object,
such as the user. Workflow variables are defined in the properties of the workflow or by
scripted activities.
{#SWF-inputs__table_ry3_4h1_qfb__entry__3}

| Name | Type | Description |
|-|-|-|
| inputs | Object | Workflow variables as name value pairs. The variables of a workflow object are custom to an integrator's implementation. |
[Table 9. Field]

{#SWF-inputs__table_ry3_4h1_qfb}  

    var user = workflow.inputs.u_user;

## Scoped Workflow - name() {#ariaid-title7}

Returns the workflow name.
{#r_SWF-name__table_wm2_spz_lt__entry__3}

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

{#r_SWF-name__table_wm2_spz_lt} {#r_SWF-name__table_xm2_spz_lt__entry__2}

| Type | Description |
|-|-|
| String | The workflow name |
[Table 11. Returns]

{#r_SWF-name__table_xm2_spz_lt}  

    var name = workflow.name();

## Scoped Workflow - removeVariable(String name) {#ariaid-title8}

Removes the specified variable from the workflow.
{#r_SWF-removeVariable_S__table_d2r_ysz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The variable name |
[Table 12. Parameters]

{#r_SWF-removeVariable_S__table_d2r_ysz_lt} {#r_SWF-removeVariable_S__table_e2r_ysz_lt__entry__2}

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

{#r_SWF-removeVariable_S__table_e2r_ysz_lt}  

    var value = workflow.removeVariable("task");

## Scoped Workflow - result {#ariaid-title9}

Element of the workflow object that contains the workflow results.
This is not a method, but rather the element in the workflow object that contains the
results of a workflow.
{#SWF-result__table_grb_p31_qfb__entry__3}

| Name | Type | Description |
|-|-|-|
| result | String | Workflow results. |
[Table 14. Field]

{#SWF-result__table_grb_p31_qfb}  

    var wfResult = workflow.result;

## Scoped Workflow - scratchpad() {#ariaid-title10}

Returns the workflow's scratchpad object.
{#r_SWF-scratchpad__table_tfn_hpz_lt__entry__3}

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

{#r_SWF-scratchpad__table_tfn_hpz_lt} {#r_SWF-scratchpad__table_ufn_hpz_lt__entry__2}

| Type | Description |
|-|-|
| Object | The scratchpad object. |
[Table 16. Returns]

{#r_SWF-scratchpad__table_ufn_hpz_lt}  

    var scratchpad = workflow.scratchpad();

## Scoped Workflow - setResult(String result) {#ariaid-title11}

Sets the workflow's result.
{#r_SWF-setResult_S__table_zvp_stz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| result | String | The workflow's result |
[Table 17. Parameters]

{#r_SWF-setResult_S__table_zvp_stz_lt} {#r_SWF-setResult_S__table_awp_stz_lt__entry__2}

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

{#r_SWF-setResult_S__table_awp_stz_lt}  

    workflow.setResult("Success");

## Scoped Workflow - setVariable(String name, Object value) {#ariaid-title12}

Sets the specified variable to the specified value.
{#r_SWF-setVariable_S_O__table_spj_2sz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The variable name |
| value | Object | The value to be assigned to the variable. |
[Table 19. Parameters]

{#r_SWF-setVariable_S_O__table_spj_2sz_lt} {#r_SWF-setVariable_S_O__table_tpj_2sz_lt__entry__2}

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

{#r_SWF-setVariable_S_O__table_tpj_2sz_lt}  

    workflow.setVariable("task", "terrible");

## Scoped Workflow - warn(String message, Object args) {#ariaid-title13}

Adds a warning message to the log.
{#r_SWF-warn_S_O__table_gxm_qrz_lt__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to add to the log. |
| args | Object | Arguments to add to the message. |
[Table 21. Parameters]

{#r_SWF-warn_S_O__table_gxm_qrz_lt} {#r_SWF-warn_S_O__table_hxm_qrz_lt__entry__2}

| Type | Description |
|-|-|
| String | The logged message |
[Table 22. Returns]

{#r_SWF-warn_S_O__table_hxm_qrz_lt}  

    var loggedMessage = workflow.warn("Check your permissions.");


