Please help with Scratchpad if else statement
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 05:57 PM
Hello,
Currently, there a 3 approvers in an RITM.
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 07:55 PM
Hello,
Please discard my question. I was able to figured out how to get it to work. Thank you