I want to update 8238 records Active=True is it possible in servicenow

kranthi2
Tera Expert

Hi,

I want to update 8238 records Active=True is it possible in servicenow.

kranthi2_0-1702384332105.png

 

kranthi2_1-1702384351033.png

 

 

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

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]

****************************************************************************************************************

Astik Thombare
Tera Sage

Hi @kranthi2 ,

 

You can achieve this by running  below script in background script.

 

AstikThombare4_0-1702384955538.png

 

 

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

Danish Bhairag2
Tera Sage
Tera Sage

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.

 

DanishBhairag2_0-1702384903433.png

 

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.

 

DanishBhairag2_0-1702385293549.png

 

 

 

Thanks,

Danish

 

 

Aniket Chavan
Tera Sage
Tera Sage

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