Background script to make a case inactive.

sachinshivakuma
Mega Contributor

HI All,

Can anyone guide me on this.

Thanks in Advance.

4 REPLIES 4

Subhajit1
Giga Guru

Hi Sachin,


Manually get the sys_id of the record.


Then run the following query in your background script:-



var gr = new GlideRecord('Your case table name here');


gr.addQuery('sys_id', 'the sys id you manually copied');


gr.query();



while(gr.next())


{


gr.active = 'false';


gr.state = 'Closed'; // This is if you have a state on case and have a closed state


gr.update();


}


Alikutty A
Tera Sage

Hi Sachin,



Try this out, it will make all records inactive



var gr = new GlideRecord('your_case_table');   //Add your case table name here


gr.query();


while(gr.next()){


gr.active = false;


gr.update();


}



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


snehabinani26
Tera Guru

var gr = new GlideRecord('your_case_table');   //Add your case table name here


gr.addQuery() // Your condition


gr.query();


while(gr.next()){


gr.active = false;


gr.update();


}


preddy
Kilo Guru

HI Sachin,



Var gr = new GlideRecord("table name");


if(gr.get("sys_id of the record"))     // if you are doing single record   or doing for multiple records use gr.addQuery("your condition");


{


gr.active = fasle;


gr.autoSysFields(false);


gr.setWorkflow("false");


gr.state = "closed";


gr.update();



}



PS: Hit like, Helpful or Correct depending on the impact of the response