How to close RITM when respected form state changes to Close

Jahnavi_Ganta
Tera Contributor

Hello Team,

when I create a request from catalog then a RITM will be created when a RITM is approved a vendor record will be created in the table. In vendor record A questionire will be created called IQ. When we open IQ in that form we have another questionire called AI. so, here the requirement is when AI questionire state changes to cancel then automatically the IQ, vendor, RITM STATE should change to close

 

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You need a Business Rule on the table AI is, with the condition that AI is cancelled.

In the script you need to back track to IQ ->Vendor -> RITM  (

I cant write the script as i don't know how are they related and what tables are they on, plus field names and values etc.

SO i'd suggest you start writing the scrips and show here if you are stuck.

Here is rough design

var getIQ = new GlideRecord('<table of IQ>');
getIQ.addQuery('<field that relates to AI>', current.sys_id); 
getIQ.query();
if(getIQ.next())
{
 var getVendor = new GlideRecord('<table of Vendor>');
 getVendor.addQuery('<field that relates to IQ>', current.sys_id); 
 getVendor.query();
 if(getVendor.next())
  {
 var getRITM = new GlideRecord('asc_req_item');
 getRITM.addQuery('<field that relates to Vendor>', current.sys_id); 
 getRITM.query();
 if(getRITM.next())
  {
//close ritm
getRITM.state=3;//use the correct state value
getRITM.update();
}
//close Vendor
getVendor.state=3;//use the correct state value
getVendor.update();
}
/close IQ
getIQ.state=3;//use the correct state value
getIQ.update();
}

 

-Anurag

Thankyou Anurag,

This helped me but the condition should work only when AI state changes to cancelled then only these 3 forms(ritm,vendor,IQ) states should be updated to closed state.

I have query like don't we use if condition.

That will be the condition for the Business Rule to run.

State <changes to><cancelled>

-Anurag