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

Rohit  Singh
Mega Sage

Hi @raj765_32 ,

 

What's the issue you are facing here? 

 

Have you tried to debug your code if your BR is not executing as per the requirement?

 

Regards,

Rohit

hi rohit,

BR is working till approver but from approver it is not working need help with code corrections

Nilesh Pol
Kilo Sage
Kilo Sage

@raj765_32 

verify through what approval getting triggered whether is workflow or flow once verify use rolledback activity, Set Record action respectively.

hi @Nilesh Pol it is getting triggered with workflow only,