How to get a subflow return value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2013 07:35 AM
In my scenario, I have two workflow's (call them A and B).
The main workflow,'A', calls the subflow 'B' (as a workflow activity). In the workflow activity where I call subflow 'B', I set the 'Map return value' to a variable that I created, called 'subflow_result'.
Workflow 'A' uses the 'Return Value Activity' to set a value based on its processing. In one path, it sets the value to be "Rejected" in the other path it sets the value to be "Approved".
In workflow 'A', immediate after the 'workflow' activity in which I call subflow 'B', I have an 'If' activity to test the result of the subflow call. Since I'm checking a variable, I've checked the advanced box in this activity and given the following script to check the variable holding the result of the subflow call:
answer = ifScript(); function ifScript() { gs.log("subflow result="+current.subflow_result); if (current.subflow_result == "Approved") return 'yes'; else return 'no'; }
This does not seem to work. I always get "subflow result=undefined" in the log. I've tried the following combinations and none seem to work:
workflow.subflow_result
workflow.var.subflow_result
workflow.scratchpad.subflow_result
Any ideas?
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2013 08:19 AM
I think I figured it out.
I set my subflow call 'Map return value' field to be:
workflow.scratchpad.subflow_result
Then in the if-activity that follows, i reference that field.
It would still be good to know how to reference non-scratchpad variables, but at least I have a workable solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 04:32 AM
The activity writes the value from the subflow value variable to the parent scratchpad.
So it can explain why it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2015 05:20 AM
You can do it you need to set 'glide.workflow.enable_input_variables'property for this. and then use the below mentioned link to follow
http://wiki.servicenow.com/index.php?title=Using_Subflows