Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

update the ritm state to closed confirmed if all sctasks corresponding to the ritm are closed

anayna
Tera Contributor

I have a query how can we update the value of the ritms which are in progress even when all the sctasks related to those ritms are closed confirmed?

 

6 REPLIES 6

Hi,

i need a fix script to update the ritm's.for eg if i have an ritm in progress state and all its 3 sctsaks are closed then my ritm should get closed confirmed. but if still one task is open then i  should not update it to close confirmed

Ashok76
Tera Contributor

Please refer my response to - Re: Database view - how we can get report if Sctas... - Page 2 - ServiceNow Community

 

You can also update in below method

var RitmNo = 'RITM0000001,RITM0000002,RITM0000003,RITM0000004,RITM0000005';
var grRitm = new GlideRecord('sc_req_item');
grRitm.addQuery('number','IN',RitmNo); // pass record numbers or have an encoded query of required records based on a time range( e,g created after october and created before december )

grRitm.addQuery('state',"NOT IN",'3,4,7'); 
grRitm.query();
while(grRitm.next())
{

var ValidateOpenTask = new GlideRecord('sc_task');
ValidateOpenTask.addQuery('request_item.number',grRitm.number);
ValidateOpenTask.addQuery('state','NOT IN','3,4,7');
ValidateOpenTask.query();
if(!ValidateOpenTask.next())
{

grRitm.state = 3; // check right values

grRitm.active = false;
grRitm.setWorkflow(false);
grRitm.update();
}

}

 

Do mark helpful if this helps

 

Regards,

Ashok