The CreatorCon Call for Content is officially open! Get started here.

Please help with Scratchpad if else statement

Radhika11
Tera Contributor

Hello,

Currently, there a 3 approvers in an RITM.

Radhika11_0-1695170926795.png

I would like scratchpad to check again the approval table to make sure all approvers have approved the RITM.

If all approved, then set the: 

g_scratchpad.flag = 1
else
g_scratchpad.flag = 0;
 

Here what I have done so far, but it is not working.  Please help.  Thank you

Business Rule:

(function executeRule(current, previous /*null when async*/ ) {
    var st = '';
    var number = current.sys_id;
    var gr = new GlideRecord("sysapproval_approver");
    gr.addQuery('sysapproval', number); //current RITM sys id
    gr.addQuery('state''approved');
    gr.query();
 
    while (gr.next()) {
        st = gr.state;
    }
    if (st == 'approved') {
        g_scratchpad.flag = 1;
    }

    if (st == 'requested') {
        g_scratchpad.flag = 0;
    }

})(current, previous);
 
Client Script:
function onLoad() {
    // Catalog Item:  Requestor 1
    if (g_form.getValue('cat_item') == '8270d48697b32110069cbbe3a253af92') {
        if (g_scratchpad.flag == 1) {
            alert(g_scratchpad.flag + ' Approved ');
        
        } else {
            alert(g_scratchpad.flag + ' Requested');
        
        }
    }

}

 

 

1 REPLY 1

Radhika11
Tera Contributor

Hello, 

Please discard my question.  I was able to figured out how to get it to work.  Thank you