- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 12:13 PM
I want to write a fix script for a list of records in a table. There is a field in my form that has a particular type of value. I want to remove that value and make it empty,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 01:44 PM
var tab = new GlideRecord('your_table');
tab.addEncodedQuery('Your_encoded_query_here');
tab.query();
while(tab.next()){
tab.your_field_name = '';
tab.setWorkflow(false); //helps in prevent running of BR's while updating
tab.autoSysFields(false);
tab.deleteRecord();
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 12:51 PM
To add, you may want to add SetWorkflow(false) to your script when you are mass updating records with a background script.
Note: Scripts - Background should be used very carefully and only in non-production environments. Free-form JavaScript can negatively impact data and system performance.
https://developer.servicenow.com/blog.do?p=/post/training-scriptsbg/
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 01:03 PM
Hi Sayan,
When you will write the script to empty the field value make sure you take only limited number of records to run the script. I ma not sure how many reocrd you have with such values but I would recomment to limit 1000 records at a time. That works for me when I do such update.
Thanks
Santosh