ATF - How to pass the Previous Step in the Run server-side script for CAB approval.

BalajiG48791808
Tera Contributor

Hi, I am trying to pass the previous step in the sys id (Insert record) in the Run server-side script step. I am writing the script to Approve 60% of approvers in the CAB approval of change request to move next phase.  Help me out its Urgent!

Error: 


Test failed due to JavaScript error executing step:
java.lang.IllegalArgumentException: Step id 3 is not valid

Full logging from step execution:
09:11:22.858 Loading script: jasmine_lib/jasmine31.js
09:11:23.251 Successfully loaded jasmine_lib/jasmine31.js


code:

(function(outputs, steps, params, stepResult, assertEqual) {

    var changeSysId = steps(3).record_id + '';

    var approvals = new GlideRecord('sysapproval_approver');
    var qc = approvals.addQuery('sysapproval', changeSysId);
    qc.addOrCondition('document_id', changeSysId);
    approvals.addQuery('state', 'requested');
    approvals.orderBy('sys_created_on');
    approvals.query();

    var total = approvals.getRowCount();
    var required = Math.ceil(total * 0.60);
    var count = 0;

    approvals.query();

    while (approvals.next()) {
        approvals.state = 'approved';
        approvals.update();

        count++;

        if (count >= required) {
            break;
        }
    }

    stepResult.setSuccess();
    return true;

})(outputs, steps, params, stepResult, assertEqual);



0 REPLIES 0