- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 08:04 AM
Hello,
I have to update multiple records in scoped app but when i tried to update record using updateMultiple(), it is not working.
Script :
var gr = new GlideRecord('x_hclan_gbs_financ_p2p_request');
gr.addEncodedQuery("numberINP2P6688772,P2P6689407,P2P6689784,P2P6690341,P2P6690659");
gr.query();
gr.state = 7;
gr.work_notes="We are closing this ticket as per the request through the story : STRY0163997";
gr.updateMultiple();
Please suggest what is wrong in the script.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 12:25 AM
Hey, I think the updateMultiple does not work with Journal entries.
you will have to loop through and update each record.
updateMultiple()
Updates each GlideRecord in a stated query with a specified set of changes.
This method does not support adding multiple journal entries.
Note: To ensure expected results, use the setValue() method instead of direct assignments. That is, use gr.setValue('<field_name>', '4')); instead of gr.<field_name> = 4.
Note: Do not use this method with the chooseWindow() or setLimit() methods when working with large tables.
This method sets new values and does not clear existing values. To clear an existing value, use the setValue() method and set the field to null.
If this helps, please mark the answer correct/helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 08:09 AM
Can you add this line after gr.query() to see if it's even returning the correct number of records
gs.info(gr.getRowCount());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 08:25 AM
Hello,
Try below
var gr = new GlideRecord('x_hclan_gbs_financ_p2p_request');
gr.addEncodedQuery("numberINP2P6688772,P2P6689407,P2P6689784,P2P6690341,P2P6690659");
gr.query();
while(gr.next())
{
gr.state = 7;
gr.work_notes="We are closing this ticket as per the request through the story : STRY0163997";
gr.updateMultiple();
}
Please note it is always advisable to use setWorkflow(false) as well but it will not update work notes because work notes is a journal field but try in lower instance and see impact of script without using setWorkflow(false).
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 11:40 PM
Hello Musab,
I want to update worknote also.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 02:41 AM
Try this in lower instance, I have not used setWorkflow(false) so first see if it has any acceptable impact if not then you can run this, Also as I said earlier you need different approach to update worknotes if you use setWorkflow(false) but I'm unable to find any thread on that so as of now take this.
var gr = new GlideRecord('x_hclan_gbs_financ_p2p_request');
gr.addEncodedQuery("numberINP2P6688772,P2P6689407,P2P6689784,P2P6690341,P2P6690659");
gr.query();
while(gr.next())
{
gr.state = 7;
gr.work_notes="We are closing this ticket as per the request through the story : STRY0163997";
gr.update();
}
Regards,
Musab