Wait for CHG to be in Scheduled State and then update RITM variable

erin-marie
Tera Contributor

I have a workflow for a catalog item that we would like to hold until a CHG has reached the Scheduled State.  The form asks for the CHG number in a reference field (currently no conditions).  I have a checkbox on the Catalog Item (which will be hidden) that is called CHG Approved.  I have a Wait for Condition that waits for the box to be checked before continuing the workflow.  There is a Business Rule that is supposed to check the box but the BR isn't working.

 

BR

Table: change_request

When to Run: Before Update

Conditions: State changes to Scheduled

                     OR State is one of Scheduled, Implement, Review, Closed

Advanced Actions:

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

    // Add your code here

    var aws = new GlideRecord('sc_req_item');

    aws.addQuery('sys_id', aws.sc_aws_assetdecom_change_request);

    aws.query();
    while (aws.next()) {
        aws.sc_aws_assetdecom_chg_approved = true;
        aws.update();

    }
})(current, previous);
 
Any assistance is appreciated.
Erin