- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 09:33 AM
Hello,
I ran into a roadblock with making a variable mandatory when another variable becomes true. I created a catalog client script but I believe my code is wrong. Has anyone run into this issue?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 11:45 AM
Change the type to Onchange and try with this
var m = g_form.getValue("concur").toString();
if (m.indexOf("true") > -1) {
g_form.setMandatory("approver_name", true);
} else {
g_form.setMandatory("approver_name", false);
}
Thanks,
Narsing

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 10:21 AM
The script should work even if concur variable belongs to a different variable set. Ultimately all fields are getting added to the form. Did you check if the script is working for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 10:38 AM
I kept the code but sadly it's not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 09:39 AM
Hi,
You have created onLoad client script. I believe when form was loaded the variable was unchecked.
You can achieve this using onChange Client script that should run on Change of Variable Concur.
But best option would be to create UI Policy instead of client script.
1. Create UI Policy with condition "Concur is True"
and in UI Policy action add action to make your variable mandatory.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 11:45 AM
Change the type to Onchange and try with this
var m = g_form.getValue("concur").toString();
if (m.indexOf("true") > -1) {
g_form.setMandatory("approver_name", true);
} else {
g_form.setMandatory("approver_name", false);
}
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 12:35 PM
Thank you, that worked!!!!