Call Subflow from UI Action and set value for a field
- 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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:42 AM
did a quick lookup and this example should help, check executeSubflow function here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:51 AM - edited ‎03-13-2024 04:53 AM
Hello @Anurag Tripathi , thank you for your assistance. I'm able to call the subflow, but I'm encountering difficulty setting the field value for the cause notes. It's displaying the sys_id for the cause note instead. I hope this clarifies the requirement. Could you please provide guidance? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:48 AM
Hi,
Check the subflow. Output of subflow should be change number instead of sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2024 04:55 AM
Hello @Shruti
My output variable is of referenced type, which is why it's displaying the sys_id. While it's the correct sys_id of that record, I actually need the change number instead of sys_id. Could you please guide me on how to achieve this? Thank you.