- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 02:03 AM
Hello,
Could yo help on below issue ?
I have to make visible variable in RITM only if below requirements will be passed:
For example, for variable1
If [Variable2]= No AND [Variable3]= No
OR
If [Variable2]= Yes OR [Variable3]= Yes, AND required approval is granted from Single Approval
OR
If [Variable2]= Yes AND [Variable3]= Yes, AND both required approvals are granted (from Single Approval and Group Approval)
I made a below catalog client script which Applies on Requested Items, but it did not work.
function onLoad() {
//Type appropriate comment here, and begin script below
if (variables.variable2== 'No' && variables.variable3== 'No') {
if (variables.variable2== 'Yes' || variables.variable3== 'Yes' && g_scratchpad.isApproved == 'true') {
if (variables.variable2== 'Yes' && variables.variable3== 'Yes' && g_scratchpad.isApproved == 'true') {
g_form.setDisplay(‘variables.variable1’,true);
g_form.setMandatory(‘variables.variable1’,true);
}
}
}
}
Thank you for any help.
Regards,
Lukas
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 03:00 AM
Hi,
so the display BR is on RITM table then this line is wrong;
update this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.addQuery("state", "approved");
gr.query();
if (gr.next()) {
g_scratchpad.isApproved = 'true';
}
g_scratchpad.isApproved = 'false';
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 03:00 AM
Hi,
so the display BR is on RITM table then this line is wrong;
update this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.addQuery("state", "approved");
gr.query();
if (gr.next()) {
g_scratchpad.isApproved = 'true';
}
g_scratchpad.isApproved = 'false';
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 03:16 AM
Unfortunately still variable1 is visible after RITM is created, before met the condition and before Approval. What should be checked next ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 04:35 AM
Hi,
things to check
1) your client script should be normal one and not catalog client script
2) check in client script by adding alert what value you get for variables and debug
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 05:02 AM
Regarding to the point 1), client script should by Type = onLoad, true ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 06:12 AM
Hi,
correct normal client script onLoad on RITM table
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader