Query in requested item

servicenow lath
Tera Contributor

In order guide( new Hire) .

All the Requested item is closed complete--> but the Request_State is not changing to closed complete.

 

 

 

 

1 ACCEPTED SOLUTION

Ratnakar7
Mega Sage
Mega Sage

Hi @servicenow lath ,

 

As per my last post(How to close a RITM when the SC task is completed in Flow designer ), there's no need to write extra code,Instead, at the end of the workflow (at the End workflow activity), if we set the "stage" to "Completed" then we have OOB business rules, which would turn the RITM stage to "completed" and state to "close complete" .

You just need to set "stage' as 'Completed' at the end of your Flow /Workflow of RITM.

Please find below screenshots:

#Flow:

Ratnakar7_0-1679298951856.png

Ratnakar7_2-1679299324906.png

 

#Workflow:

Ratnakar7_1-1679299146465.png

 

 

Thanks,

Ratnakar

View solution in original post

5 REPLIES 5

Ratnakar7
Mega Sage
Mega Sage

hi @servicenow lath ,

 

You can follow below steps in flow designer:

  1. Add a "Query Records" action to the flow and configure it to query for all Requested Items related to the specific Request.
  2. Add a "Check Condition" action to the flow and configure it to check if all of the Requested Items in the result set have a State of Closed Complete.
  3. If all of the Requested Items are Closed Complete, add an "Update Record" action to the flow and configure it to update the Request record's Request_State to Closed Complete.
  4. Save and activate the flow.

 

If my response helps you to resolve the issue close the question by Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.

 

Thanks,

Ratnakar

Ratnakar7
Mega Sage
Mega Sage

Hi @servicenow lath ,

 

Please try with below Business Rule Script:
Create new BR on sc_req_item table , like below:

Ratnakar7_0-1679057551046.png

 

Ratnakar7_1-1679057568970.png

 

(function executeRule(current, previous /*null when async*/) {

var reqItemGr =new GlideRecord('sc_req_item');
reqItemGr.addEncodedQuery("state!=3^request="+reqItemGr.request); //check for all other  RITM status
reqItemGr.query();
if(reqItemGr.getRowCount()==0){ //If all RITM closed
	var reqGr =new GlideRecord('sc_request');
	reqGr.get(reqItemGr.request);
	if(reqGr.request_state!="closed_complete"){
		reqGr.setValue('request_state',"closed_complete"); //update Req to close
		reqGr.update();
	}
}

})(current, previous);

 

Thanks,

Ratnakar

Ratnakar7
Mega Sage
Mega Sage

Hi @servicenow lath ,

 

Alternatively you can Add an update action with Flow Designer and set the RITM stage to Completed. This will trigger business rules to close the RITM and the Request.

 

Please refer below KB articles:

How to close a RITM when the SC task is completed in Flow designer 

Request is not closing when all RITM & SCTASK tickets under it are closed 

 

If my response helps you to resolve the issue close the question by Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.

 

Thanks,

Ratnakar

@Ratnakar7 As Per Your suggestions i have created a Flow designer and BUsinees rule. 

But in the Sc_request Record the Request_state value is not changing to closed_complete. 

how to  solve this issue??

1903e.jpg

1903a.jpg1903b.jpg1903c.jpg1903d.jpg