- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 10:39 AM
I've defined a workflow that could be called both as a subflow (i.e. from another workflow) and now I would like to call this workflow from a script.
After reading http://wiki.servicenow.com/index.php?title=Workflow_Script#startFlow.28workflowId.2C_current.2C_oper..., I am not sure that the "startFlow()" vars parameter will translate into input parameters which get accessed by the called workflow via workflow.inputs.<variable name> or whether they will become variables which get accessed in the workflow by current.variables.<variable name>
Since I've coded the workflow to access the parameters via workflow.inputs I'm not sure how to invoke this workflow using the startFlow() API (from the Workflow script include). Has anyone done this or could anyone offer insight as to how one should develop a workflow that works with input parameters and can be called both as a subflow as well as directly from some script?
Thanks in advance for any insights.
Ty
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 10:45 AM
Hello Ty,
You would pass the variables as a JSON name:value pair like:
wf.startFlow(wfId, null, "Workflow Name", {input_var_name: input_var_value});
Using Variables in a Workflow - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 10:45 AM
Hello Ty,
You would pass the variables as a JSON name:value pair like:
wf.startFlow(wfId, null, "Workflow Name", {input_var_name: input_var_value});
Using Variables in a Workflow - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 11:45 AM
Hi Robert,
Well, it appears that you are correct. Thanks!
It took me a second to verify because when I went to create a test workflow that uses the sc_req_item, the "Edit Inputs" option no longer appeared (whereas in our company instance, it does appear) and that sent me on a loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 01:00 PM
Also, just fyi, it seems that by default, service now does not allow you to enter input variables for workflow items using sc_req_item. Any other table lets you define inputs (i.e. "Edit Inputs" option exists under the properties pulldown unless the table is sc_req_item, then that option does not exist).
The work around here is that you need to set a system property called "glide.workflow.enable_input_variables" to true