The CreatorCon Call for Content is officially open! Get started here.

If RITM state is set to closed incomplete, the relevant request should get closed incomplete

arundharmabe
Tera Guru

Hello Genius,

I have a small requirement, If RITM state is set to closed incomplete, the relevant request should get closed incomplete. Due to workflow it is not updating it properly. Can any one help me on this please.

Kindly note, when the RITM is set to Closed Incomplete, we have to set RITM stage as closed incomplete & RITM Approval as "Rejected" and REQ Request state as "Closed Incomplete" & REQ Approval as "Rejected". I have tried few ways but no luck.

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

Hi Arun,



I have tried below Business rule on after insert/update on sc_req_item and it's working, please try and see if it helps.



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


  // Add your code here


  var req_item = new GlideRecord('sc_req_item');


  req_item.get(current.sys_id);



  if(req_item.state =='4')


  {//Set your appropriate state here


  req_item.stage ='Closed Incomplete';


  req_item.approval = 'Rejected';


  req_item.update();



  var req = new GlideRecord('sc_request');


  req.get(req_item.getValue('request'));


  req.request_state = 'Closed Incomplete';


  req.approval = 'Rejected';


  req.update();


  }


})(current, previous);



BR Configuration:



find_real_file.png


find_real_file.png


View solution in original post

10 REPLIES 10

Hi Shishir,



You made my day. It's working great. Your help is highly appreciatable. Sorry i don't know how to make this as correct answer.


Hi Arun,



Thank you for your valuable feedback, please check How to Mark Answers Correct From Inbox View.



Hi dan.bruhn : Please help.



Done:)


Hi Shishir,



One more additional question, if we have more than one RITM for a single REQ, how we can control that.



For Ex:



I want to set REQ state to closed Incomplete only if all the RITM's set to closed incomplete. If 1 RITM is set to closed incomplete and the another one is set to closed complete then it should set REQ state as closed Complete. Kindly advise how we can achieve this.


Hi Arun,



This should help:



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


  // Add your code here


  var req_item = new GlideRecord('sc_req_item');


  req_item.addQuery('request', current.request);


  req_item.addQuery('state', '3');


  req_item.query();


  if(req.next())


  {


  var req = new GlideRecord('sc_request');


  req.get(req_item.getValue('request'));


  req.request_state = '3';


  req.update();


  }


})(current, previous);