Workflow Variable Returning Undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 11:53 AM
I am running this simple script in a run script activity for a workflow running on the rm_enhancement table:
workflow.variables.skip = 'no';
gs.log('Beginning= ' + workflow.variables.skip,'EnhancementApprovals');
The log keeps returning "Beginning = undefined". What am I missing? Why can I not set a workflow variable in this workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 11:57 AM
Hi Kristen,
You can only get the workflow variables which are defined in input.
if your workflow is having one of the input variable with name as skip then workflow.variables.skip would give you some value.
Usually workflow variables are used when you call sub workflow in main workflow and pass variables to sub workflow and define workflow input variables to hold those values.
https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/using-workflows/concept/c_UsingVariablesInAWorkflow.html
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 11:26 PM
Hi,
I tried the same you said, I declared same var_name in edit inputs section, as was in startFlow() passed {name:value}.
I was updating current record field value, in workflow Run Script activity, but nothing was updated ,as it's showing nothing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 11:50 PM
check this link where I have shared solution with example on passing the inputs to workflow
Please mark that response as helpful
Trouble Accessing variables from inbound action
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 12:11 PM