- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 02:52 PM
I'm failing to launch a flow from a Run Script activity. My goal is to use this Run Script action (in a Workflow) to launch the Flow, so that the Flow can do what it does.
Run Script action:
try {
var inputs = {};
inputs['table_name'] = 'sc_req_item';
inputs['request_item'] = current.sys_id; // GlideRecord of table: sc_req_item
workflow.info('Requested Item: ' + current.number + ', sys_id: ' + current.sys_id);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.getRunner().flow('global.create_user').inForeground().withInputs(inputs).run();
workflow.info('Launched "Create User" flow in Flow Designer');
} catch (ex) {
var message = ex.getMessage();
workflow.info("Failed to launch the Flow in Flow Designer: " + message);
gs.error(message);
}
What I'm getting back in the workflow log is:
What do I need to feed the inputs['request_item'] for this to work?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 05:37 PM
To successfully launch a flow (or action) from Flow Designer, use the entire code snippet provided by Flow Designer in your action. From there, you can use current to populate the inputs['request_item'] value:
var inputs = {};
inputs['table_name'] = 'sc_req_item'; // This starts as 'Table Name', and you have to set it.
inputs['request_item'] = current; //GlideRecord of table: sc_req_item
Where you'll run into issues is if you aren't actually handling the possible responses from the overall flow execution; avoid logging in the catch part of the try/catch block because it'll hit that part while the flow is waiting to complete (if you have a single 'wait' activity in there).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 02:56 PM
tried this:
var currentReq = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sys_id);
gr.query();
try {
var inputs = {};
inputs['table_name'] = 'sc_req_item';
inputs['request_item'] = currentReq; // GlideRecord of table: sc_req_item
workflow.info('Requested Item: ' + current.number + ', sys_id: ' + current.sys_id);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.getRunner().flow('global.create_user').inForeground().withInputs(inputs).run();
workflow.info('Launched "Create User" flow in Flow Designer');
} catch (ex) {
var message = ex.getMessage();
workflow.info("Failed to launch the Flow in Flow Designer: " + message);
gs.error(message);
}
but it resulted in a more generic error:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 05:37 PM
To successfully launch a flow (or action) from Flow Designer, use the entire code snippet provided by Flow Designer in your action. From there, you can use current to populate the inputs['request_item'] value:
var inputs = {};
inputs['table_name'] = 'sc_req_item'; // This starts as 'Table Name', and you have to set it.
inputs['request_item'] = current; //GlideRecord of table: sc_req_item
Where you'll run into issues is if you aren't actually handling the possible responses from the overall flow execution; avoid logging in the catch part of the try/catch block because it'll hit that part while the flow is waiting to complete (if you have a single 'wait' activity in there).