how can i stop background script???

Kishore8
Kilo Guru

how can i stop/ delete   background script.

actually i have assigned a role to 577 managers a time., now i want to remove that role from 577 managers...............how can

11 REPLIES 11

BALAJI40
Mega Sage

Hi Kishore,



DId the background script was run and updated?



If updated means you need to run again same background script with the same query and this time not for update but it for delete operation.



var gr = new GlideRecord('sys_user_has_role');


gr.addEncodedQuery(your query condition);


gr.deleteMultiple()


i think this not right way...



if we use gr.deleteMultiple()


deleted reaming roles also....please chek once...



i tested deleted reaming roles also..


HI D Kishore,



Assuming all this records are created today and you dont have any other records created today in sys_user_has_role table.



var gr = new GlideRecord("sys_user_has_role");


gr.addEncodedQuery("sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)");


gr.query();


while(gr.next()){


gr.deleteRecord();


}



Hope this helps you.


See the only difference between deleteMultiple and deleteRecord are, deleteRecord will delete entire record, but deleteMultile except attachment   deletes entire record. That's it.


you are telling, it deletes remaining roles also means I guess your query condition may be wrong please check once.


Hi D-Kishore,



I assume this is already answered in a separate thread and you are satisfied with the result. Can you please mark the answer as correct/helpful and close this thread.