update the ritm state to closed confirmed if all sctasks corresponding to the ritm are closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 04:25 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 08:42 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 09:17 AM
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