- 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-02-2025 02:07 AM
Hi @WaseemM
Using 2 action is recommended as 2 different table records need to update.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 02:25 AM
Hi @WaseemM ,
You can try to create script action and in script action you can use Glide Record for two different table and update the value depending upon your use case.
But it's recommended and good practice to create two different actions for updating the record though the flow will be a bit long but it will be easy to maintain and change the flow in future.
If my response helped, please mark it helpful and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 08:01 AM
Hi @WaseemM
Hope my response helped.
If my response helped, please mark it helpful and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 04:05 AM
using OOB update record flow action only 1 record can be updated.
You can use custom flow action and either user 2 update records inside it OR single script step to update 2 records
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader