Update Set with Script

122932
Tera Expert

Hello everything is fine?

How to perform an update, by Script background, in ServiceNow?

Thanks.

9 REPLIES 9

Peter Bodelier
Giga Sage

Can you please elaborate on your use case?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hello everything is fine?

 

I need to do a massive update, I need to move from DEV to Prod, several updates per Script.

 

Thanks.

Ok, and what exactly do you need help with? The script itself, or how to call it?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

var gr = new GlideRecord('u_table');

var string='active=true^state=2';

gr.addEncodedQuery(string)

gr.query();

while(gr.next())

{

gr.setWorkflow(false);

gr.autoSysFields(false);

gr.state = 'committed';

gr.update();

}