Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

how to set approvers to no longer requested when parent ritm is cancelled

raj765_32
Tera Contributor

Hi can anyone please help me with code correction for written below:

 

requirement is that when the parent RITM is cancelled for the catalog item, the approvers need to be set to ' no longer requested' for the child RITM'S 

wriiten an after business rule and code is :

 

if (current.state == 'Canceled' && !current.parent.nil())

{

 var parentRITM = current.parent;

var grChildRITMs = new GlideRecord('sc_req_item');

grChildRITMs.addQuery('sgdc_ref', current.request);

 grChildRITMs.query();

 

while (grChildRITMs.next()) {  

if (grChildRITM.state ! = 4)

grChildRITM.state = 4;

ChildRITM.update();

}

 

var grApprovals = new GlideRecord('sysapproval_approver');

grApprovals.addQuery('document _id', grChildRITMs);

 grApprovals.addQuery('state', '!=', 'closed');

 grApprovals.query();

while (grApprovals.next()) {

 grApprovals.state = 'not_requested';

 grApprovals.update(); } }

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@raj765_32 

please share complete business rule script and BR is on which table and what's the condition?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader