Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

I would like delete the multiple users in the user table ,By the background script

Hari Babu
Mega Expert

Hi Friends,

I would like delete the multiple users in the  user table ,By the background script 

Can you please share me the script .

 

Regards,

Jagadeesh

1 ACCEPTED SOLUTION

Hari Babu
Mega Expert

Tq Guys , for your support,

 

 

 

Regards,

Jagadeesh

View solution in original post

7 REPLIES 7

VigneshMC
Mega Sage

Try 

var user = new GlideRecord('sys_user');
user.addEncodedQuery('');//add your query;
user.query();
while(user.next()){
	user.deleteRecord();
}

Raju Koyagura
Tera Guru

Use below script and change the query as you need...

var gr = new GlideRecord('sys_user')
//gr.addEncodedQuery('active=false');
gr.addQuery('active','false'); //to delete all inactive users
gr.deleteMultiple();

Raj68
Mega Guru

var gr = new GlideRecord('sys_user');

 

 

gr.query();

 

while (gr.next()) {

 

  gr.deleteMultiple(); 

}

Raj68
Mega Guru

Hi Jagadeesh,

Please go through below code may be it will help you:

 

var gr = new GlideRecord('sys_user');

 

 

gr.query();

 

while (gr.next()) {

 

  gr.deleteMultiple();

 

}

 

NOTE: Mark correct or helpful if it helps you.

 

 

Warm Regards,

Raj patel