Workflow Advanced Script Reference

Jeremy Hargis
Kilo Contributor

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.

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

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

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

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!

The SN Nerd
Giga Sage
Giga Sage

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