How to write a fix script to close the changes that are assigned to specific users?

Manikantahere
Tera Contributor

I need to close the change requests that are assigned to x,y,z users but unfortunately their user records are not presented in user table but i can able to see them in the change list view as seen the below.
Picture1.png

help me to write a code to query records through fix script?

6 REPLIES 6

Neel Patel3
Giga Guru

Can you try using updated by?

If not list edit is all I can think of.

You mean directly closing them through list?

Hi @Manikantahere ,

 

if those changes are irrelevent to your business and if you have admin access you can close them via the script given by @Sai_Charan_K , that must work.

 

before you execute such script mark sure to pass the right value in the encoded query and cross verify the counts in list view before execution. 

 

i hope this helps...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Sai_Charan_K
Kilo Sage

Hi @Manikantahere,

Assuming that the user's mail ids are available in the created by column, I have written a script, Please try this script in the dev instance and verify.

 

var gr = new GlideRecord("change_request");
gr.addEncodedQuery("sys_created_by=felix.bait"); //filtered using created by email and copied the query
gr.query();
while (gr.next()) {
    gs.print(gr.number);
    gr.state = "3"; //closed state value
    gr.close_code = "successful"; //close code value
    gr.close_notes = "Test Successful"; //close notes comments
    gr.setWorkflow(false);
    gr.update();
}

 

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

Thanks and Regards,

K. Sai Charan