Background script to change the status of the RITM

Kiddy1
Tera Contributor

CAN WE CHANGE THE STATUS OF RITM through background script?

6 REPLIES 6

BALAJI40
Mega Sage

yes we can change the status of RITM, can i know what you want to update on RITM?


Ahmed Hmeid1
Kilo Guru

var gr = new GlideRecord('sc_req_item');


gr.addQuery('number', 'RITMxxxxx');


gr.setLimit(1);


gr.query();


if (gr.next()) {


gr.state = new state;


//gr.setWorkflow(false) - do this if you want to update the state without running workflow or business rules



gr.update;


}


shloke04
Kilo Patron

Hi,



Yes it can be done using Background Script. Please refer the script below:



Script:



var gr = new GlideRecord('sc_req_item');


var string='active=true';                                       //Replace your query here.


gr.addEncodedQuery(string)


gr.query();


while(gr.next())


{


gr.setWorkflow(false);


gr.autoSysFields(false);


gr.state= '2';                                                                                             //Replace '2' with your Complete status Value


gr.update();


}



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi,



If your query is Resolved, would you mind marking my answer as correct and close this thread.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke