- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2021 01:42 AM
I need to update couple of the records with the help of the background script. The field I need to update is a free text field, which = to value NAAM. I need to update it so it says NAM.
Here's the script I'm using but it's not working - anyone knows why?
var rg = new GlideRecord('incident');
rg.addQuery("u_alias1", "=", "NAAM");
rg.query();
while(rg.next){
rg.u_alias1="NAM";
rg.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2021 01:44 AM
try with
var rg = new GlideRecord('incident');
rg.addQuery("u_alias1", "=", "NAAM");
rg.query();
while(rg.next()){
rg.setValue('u_alias1','NAM');
rg.update();
}
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 06:24 AM
Hi Rohila
Never directly assign a value to a variable and call multipleUpdate()!
That will cause all records of the table to have the value changed whatever the query!!
Always use .setValue() together with updateMultiple()!
Please fix your comment or remove it before someone, for some reason, decides to use your way of updating the records and actually destroy data in the table!
Best regards
Nuno Agapito
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 06:44 AM
Thank You Nuno, I modified the code.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP