updateMultiple() is not working while using in fix script

Shweta Mayekar
Tera Contributor

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

1 ACCEPTED SOLUTION

prashanth2
Kilo Guru

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.

https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/no-namespace/c_GlideRecordScope...

 

If this helps, please mark the answer correct/helpful.

View solution in original post

6 REPLIES 6

SuhasPSalunkhe
Kilo Guru

1. Please check getrowcount

2. If count is there and it will not work then add your code in Try Catch block. You will get exact error.

 

 

prashanth2
Kilo Guru

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.

https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/no-namespace/c_GlideRecordScope...

 

If this helps, please mark the answer correct/helpful.