Script in UI Action does not call Subflow...
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 12:10 AM
Since I noticed that Flow does not have an option to set “Requested Item” table as trigger unfortunately, I decided to call Subflow from UI Action as plan-B.
I created an UI Action button in “Requested Item” table that changes “Approval” field value to “requested” and calls a Subflow that runs "Request for approval" Action.
By clicking on the button, it successfully changes the field value, but doesn’t call the Subflow. Could someone please help me with troubleshooting?
current.approval = 'requested';
current.update();
(function() {
try {
var rec_id = current.sys_id;
var gr = new GlideRecord(current.getTableName());
if (gr.get(rec_id)) {
var inputs = {};
inputs['ritm'] = rec_id;
// Start Asynchronously: Uncomment to run in background.
// sn_fd.FlowAPI.startFlow('flow name', inputs);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.executeFlow('global.poc_approval_subflow', inputs);
}
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
action.setRedirectURL(current);
Best Regards,
Aki
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 06:45 AM
Try the new flow API:
current.approval = 'requested';
current.update();
(function() {
try {
var rec_id = current.sys_id;
var gr = new GlideRecord(current.getTableName());
if (gr.get(rec_id)) {
var inputs = {};
inputs['ritm'] = rec_id;
// Start Asynchronously: Uncomment to run in background.
// sn_fd.FlowAPI.startFlow('flow name', inputs);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.getRunner()
.subflow('global.poc_approval_subflow')
.inForeground()
.withInputs(inputs)
.run();
}
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
action.setRedirectURL(current);