
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 02:20 PM
All:
I have created the following UI Action to execute a flow but it is not working.
(function() {
try {
var rec_id = g_form.getUniqueValue();
var gr = new GlideRecord('x_cpts_onboarding_cpts_referral_data');
var inputs = {};
inputs['current'] = gr.get(rec_id); // GlideRecord of table:
inputs['table_name'] = 'x_cpts_onboarding_cpts_referral_data';
// Start Asynchronously: Uncomment to run in background.
// sn_fd.FlowAPI.startFlow('x_cpts_onboarding.invite_to_apply', inputs);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.executeFlow('x_cpts_onboarding.invite_to_apply', inputs);
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
The trigger condition I have set in the flow is for a record update and not create.
Per an earlier community post
https://community.servicenow.com/community?id=community_question&sys_id=d25c8167db00149c23f4a345ca9619d5
I have also set the When to Run the Flow value to "Run for non-Interactive Session", but the flow is still not triggering.
Appreciate any assistance from this group.
Mahesh
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:34 PM
Hi,
Try this. This is server side code snippet so please make sure you run this on the server side of UI action.
(function() {
try {
var rec_id = current.sys_id;
var gr = new GlideRecord('x_cpts_onboarding_cpts_referral_data');
if (gr.get(rec_id)) {
var inputs = {};
inputs['current'] = current; // GlideRecord of table:
inputs['table_name'] = 'x_cpts_onboarding_cpts_referral_data';
// Start Asynchronously: Uncomment to run in background.
// sn_fd.FlowAPI.startFlow('x_cpts_onboarding.invite_to_apply', inputs);
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.executeFlow('x_cpts_onboarding.invite_to_apply', inputs);
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
}
})();
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 12:55 PM
This is great! Thank you for sharing. It wasn't obvious to me (it should have been), but I created the flow in Global but then tried to call it from a scoped app and had to include the global scope, ie. executeFlow('global.my_flow', inputs).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 11:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 04:25 AM
I have created similar script to execute a flow with input. The flow executes fine but it does not give execution logs
Could you please help me here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 01:50 AM
Hello,
Try this: This is a server-side code snippet, so please ensure you run it on the server side of the UI action.
(function() {
try {
var inputs = {};
inputs['current'] = ; // GlideRecord of table:
inputs['changed_fields'] = ; // Array.Object
inputs['table_name'] = 'table_name';
// Start Asynchronously: Uncomment to run in background.
// sn_fd.FlowAPI.getRunner().flow('flow.name').inBackground().withInputs(inputs).run();
// Execute Synchronously: Run in foreground.
sn_fd.FlowAPI.getRunner().flow('flow.name').inForeground().withInputs(inputs).run();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
Try this: This is a client-side code snippet, so please ensure you run it on the server side of the UI action.
(function() {
var inputs = {};
inputs['current'] = { // GlideRecord
table : '',
sys_id :
};
inputs['changed_fields'] = ; // Array.Object
inputs['table_name'] = 'tablename';
GlideFlow.startFlow('flowbackendname', inputs)
})();
Thank You,
Mohd Aqib