
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 12:07 PM
Hello,
I am attempting to move future code into the Flow Designer since it was beefed up for New York. I have run into the issue where I would like to pass "RESTAPIRequest request, RESTAPIResponse response" variables into flow designer via a script call. This is being done in a Scripted REST Resource, so I have the parameters defined by the Script field itself.
I have tried Object and just passed in request and response, but flow throws an error as the object is a complex object.
I have tried JSON and String (JSON into a String input), but both lose the object itself. Similar to stringifying a GlideRecord aka request.body == undefined.
None of the other types seem to fit, but I am curious if someone else made this work by just passing in the two variables.
I decided to go ahead and create separate inputs for each bit of data I need from the variables though that is not too scalable if request and response get enhancements or changes in the future.
The call is copied from the code snippet from the subflow and with inputs it looks like this:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
var inputs = {};
inputs['request'] = JSON.stringify(request); // JSON
inputs['response'] = JSON.stringify(response); // JSON
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var outputs = sn_fd.FlowAPI.executeSubflow('subflow_name', inputs);
// Current subflow has no outputs defined.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})(request, response);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 02:59 PM
The script action is available in Flow Designer without Integration Hub I believe, you only need Integration Hub if you're planning to make an out-bound call in your script (e.g. RestMessageV2), in your case you're just processing some inbound JSON so you should be good to go with just regular Flow Designer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 02:59 PM
The script action is available in Flow Designer without Integration Hub I believe, you only need Integration Hub if you're planning to make an out-bound call in your script (e.g. RestMessageV2), in your case you're just processing some inbound JSON so you should be good to go with just regular Flow Designer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 11:06 AM
Correct, the script action is, but what they're passing in as the Request is from a REST action only available in integration hub.
(example: https://developer.servicenow.com/app.do/app.do#!/lp/servicenow_application_developer/app_store_learn... on the step for "Add the REST Step with an Inline Connection")
This is where they perform the same functionality found in Scripted REST APIS/Resources (where I'm starting). Effectively, I don't have access to the "Request" type for Inputs, which you helped me confirm. I will wind up creating a custom Request object to pass in as JSON and parse as you mentioned.
A bit convoluted, but the best solution in this situation is a custom object passed as JSON.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 09:52 PM
@Michael Ruddick