Call Subflow from UI Action and set value for a field
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:36 AM
Hello experts,
I'm seeking assistance with calling a subflow in a UI action. Currently, I'm able to successfully call a subflow in my server-side UI action, and everything is working fine. However, I want to set the change number in the close notes of the problem. When I attempt to set the change number, it provides me with the sys_id of it. How can I access it? I have pasted my script for your reference. Please provide guidance. Thank you.
try {
var inputs = {};
inputs['short_description'] = current.short_description; // String
inputs['description'] = current.description; // String
// inputs['assignment_group'] =current.assignment_group.getDisplayValue(); // String
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.getRunner().subflow('global.create_change_request_for_incident').inBackground().withInputs(inputs).run();
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().subflow('global.create_change_request_for_incident').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
// Note: outputs can only be retrieved when executing synchronously.
var change_number = outputs['change_number']; // Reference
current.cause_notes=change_number;
current.update();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:59 AM
try {
var inputs = {};
inputs['short_description'] = current.short_description; // String
inputs['description'] = current.description; // String
// inputs['assignment_group'] =current.assignment_group.getDisplayValue(); // String
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.getRunner().subflow('global.create_change_request_for_incident').inBackground().withInputs(inputs).run();
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().subflow('global.create_change_request_for_incident').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
// Note: outputs can only be retrieved when executing synchronously.
var change_id = outputs['change_number']; // Reference
var gr_change = new GlideRecord('change_request');
if (gr_change.get(change_id)) {
var change_number = gr_change.number;
}
current.cause_notes = change_number;
current.update();
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}