I want to update 8238 records Active=True is it possible in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 04:32 AM
Hi,
I want to update 8238 records Active=True is it possible in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 04:36 AM
Yes, 2 ways, either by script on one go or by select 1 record plus down arrow key and scroll till bottom.
Double click on false and is no validation apply it wil editable select true it done.
but what records are these?
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
12-12-2023 04:36 AM - edited 12-12-2023 04:42 AM
Hi @kranthi2 ,
You can achieve this by running below script in background script.
var gr = new GlideRecord('Table Name');
gr.addQuery('active',false);
gr.query();
while(gr.next()){
gr.active= true;
gr.updateMultiple();
}
Please mark ✅ Correct if this resolves your issue, and also mark 👍 Helpful if you find my response valuable based on its impact.
Regards,
Astik Thombare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 04:47 AM - edited 12-12-2023 04:48 AM
Hi @kranthi2 ,
You can use Data Management option which is OOTB in ServiceNow. Open the table & apply the respective filter. Once applied right click on any column u will see Data management option like below. Select update all with preview.
Once selected it will open up a record like this. Under field values add Active - true & save the record (dont update). Once saved bottom left corner u will get execute now related link. press it. it will update all 8000+ records.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 04:49 AM
Hello @kranthi2 ,
Yes it is possible, you can use the below script either in fix script or in the background script.
// Create a GlideRecord for the specified table
var gr = new GlideRecord('your_table_name');
// Add a condition to find records where 'active' is currently false
gr.addQuery('active', false);
// Execute the query to find matching records
gr.query();
// Use updateMultiple to efficiently update all matching records to set 'active' to true
var numUpdated = gr.updateMultiple({ active: true });
// Log the number of records updated
gs.info('Number of records updated: ' + numUpdated);
Also if you want you can use the update job as well without any scripting.
Mark ✅Correct if this solves your issue and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket