- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2019 08:52 AM
Hello. I would like to better understand the capabilities of using the advanced script feature of workflow activities. I have seen many code snippet examples online of things which can be accomplished in this scripting area. Is there a complete reference somewhere, including the default variable names for interacting with different elements involved in the workflow? I'd like to see what is available to script against. Thanks.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 06:10 PM
You've got access to the entire server-side API, with the following additional variables / API:
current - the GlideRecord (GR) the workflow is attached to
current.variables - the variables filled out in a record producer / catalogue item
workflow.scratchpad - a place to share variables across all scripts in the workflow
activity - GR of the current workflow activity
previous_activity - GR of the previous workflow activity
answer - the return value for some scripts with conditional paths
There are more, these are just on the top of my head.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 03:36 PM
Hi Jeremy,
This might help:
Thanks,
Raf

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 04:29 PM
Hello,
Other than searching for specific use cases...there isn't a "set resource" that has every single thing you can do in a workflow as far as a script is concerned. But...you really have quite unlimited potential as it's all server side so you have access to majority of things you'd need. You'd use: current.variables.variable_name for referencing your variables and then you can assign those to workflow.scratchpad.name to then use them across the workflow even more (this allows you to manipulate input data without altering the actual variables themselves + other uses).
So...at this point, it's really up to you to decide what you'd like to do once a requirement is given or respective use case.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 06:10 PM
You've got access to the entire server-side API, with the following additional variables / API:
current - the GlideRecord (GR) the workflow is attached to
current.variables - the variables filled out in a record producer / catalogue item
workflow.scratchpad - a place to share variables across all scripts in the workflow
activity - GR of the current workflow activity
previous_activity - GR of the previous workflow activity
answer - the return value for some scripts with conditional paths
There are more, these are just on the top of my head.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022