Request (REQ) should close once the RITM is closed

Vaishnavi35
Tera Guru

Hi,

 

Once the RITM is closed the REQ is not closing.

RITM's having tasks or workflows are involved REQ is getting closed correctly.

 

But the RITM's where tasks are not there REQ form is not getting closed.

Vaishnavi35_0-1688110096037.png

 

Help?

 

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

Hi @Vaishnavi35 ,

try this 

 

(function executeRule(current, previous /*null when async*/ ) {
	var grReq = new GlideRecord('sc_request');
	grReq.addQuery('sys_id', current.request);//get the request from RITM
	grReq.query();
	if (grReq.next()) {
		grReq.request_state = 'closed_complete'; //add your field  name
		grReq.update();
	}
})(current, previous);

 

  

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

14 REPLIES 14

Hi @Vaishnavi35 ,

you can create the After Business rule on sc_req_item table and give condition as state changes to close complete. Use below script

 

 

(function executeRule(current, previous /*null when async*/ ) {
	var grReq = new GlideRecord('sc_request');
	grReq.addQuery('sys_id', current.request);//get the request from RITM
	grReq.query();
	if (grReq.next()) {
		grReq.request_state = 'closed_complete';
		grReq.update();
	}
})(current, previous);

 

 

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Hi Pavan,

 

The code does not work as the REQ record is still active even after the RITM state is moved to closed complete.

Vaishnavi35_1-1688117581668.png

 

Vaishnavi35_2-1688117624465.png

 

Thanks,

Vaishnavi

Hi @Vaishnavi35 ,

try this 

 

(function executeRule(current, previous /*null when async*/ ) {
	var grReq = new GlideRecord('sc_request');
	grReq.addQuery('sys_id', current.request);//get the request from RITM
	grReq.query();
	if (grReq.next()) {
		grReq.request_state = 'closed_complete'; //add your field  name
		grReq.update();
	}
})(current, previous);

 

  

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

@Pavankumar_1 why going for a workaround and not for the out-of-the-box business rule?

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Out-of-the-box this should work fine. I see in other replies in this topic something with a custom business rule. Nice workaround, though why? I would try to find the actual cause. Because again, out-of-the-box this should work fine.

 

Are you experiencing this for one workflow specific? Or for all?

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn