- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 01:25 AM
Hi Guys,
I need help updating multiple records in a single step in Flow Designer. For example, if my flow fails, I must update both the Request and Change Request simultaneously. However, I must use two actions, making the flow unnecessarily long.
Please let me know if there is any OOBE feature or custom action, which would be great.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:08 AM
Hello @Ankur Bawiskar ,
Thanks for your response. I have generated the JSON within JavaScript, and as suggested, it provides users with the option to select and update only the required fields. Additionally, I have hardcoded the table name since the Change Request State fields differ and do not align with the INC and RITM fields.
(function execute(inputs, outputs) {
var userinput = inputs.userinput;
var ritmnumber = inputs.ritmnumber;
var state = inputs.state;
var work_notes = inputs.work_notes;
var assigned_to = inputs.assigned_to;
var assignment_group = inputs.assignment_group;
var short_description = inputs.short_description;
var description = inputs.description;
var fields = [
{ field: "work_notes", value: work_notes },
{ field: "assigned_to", value: assigned_to },
{ field: "assignment_group", value: assignment_group },
{ field: "short_description", value: short_description },
{ field: "description", value: description },
{ field: "state", value: state }
];
// Filter out fields where the value is null or an empty string
var fieldsToUpdate = fields.filter(function(item) {
return item.value !== null && item.value !== "";
});
var gr = new GlideRecord('sc_req_item');
// Check if userinput is true
if (userinput == true) {
// Check if the RITM number is found
if (gr.get('number', ritmnumber)) {
// Iterate through the JSON array and update the fields
for (var i = 0; i < fieldsToUpdate.length; i++) {
var field = fieldsToUpdate[i].field;
var value = fieldsToUpdate[i].value;
if (field === "work_notes") {
gr.work_notes = value; // Use the work_notes property directly
} else {
gr.setValue(field, value);
}
}
gr.update();
gs.info('RITM ' + ritmnumber + ' has been updated successfully.');
} else {
gs.info('RITM ' + ritmnumber + ' not found.');
}
} else {
gs.info('User input was false, RITM update skipped.');
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 12:50 AM
Hi @WaseemM
I'm not familiar with the code, so I'm unable to help much here. Really sorry about that.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************