
- 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 12:31 PM
Parse the stringified JSON input in a script step in your Flow to turn it back into an object.
Check here for an example:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 12:46 PM
I appreciate your reply.
I'm not using a REST Action though. This is still in the Scripted REST Resource section of the platform that is then calling a subflow and passing in the provided request and response variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 01:07 PM
Yep I get that, your Scripted REST script looks correct as you posted, I was just saying to add a script step to your Subflow to parse the stringified JSON you're passing in as inputs.
Check that link I posted and look at the script in the "Creating a Script to Parse and Map Data" section, that should work for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 02:48 PM
Took me a second, but I'm following your train of thought now. That Action you mention appears only available with Integration Hub implemented. At the moment, I do not have access to Integration Hub, so I have to come up with an alternative which is the reason behind the post. I'm glad there is an OOB way to do this as I was perplexed with the tools I have available at the moment.