Force Mandatory Variable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 02:37 PM - edited 11-08-2023 08:39 PM
Hi Connections,
I have a variable. Safe Updating with three choices, when safe updating is selected, I want to push user to fill any ONE of the below variables, Standard User Role OR Safe Manager Role. How can I achieve this. any suggestions... to show that two variables i have created UI policy to appear on the form when safe updating is selected....
appreciate any help.
Best Regards,
Rafmine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 04:24 PM
Visually, you can either make both variables mandatory when they are visible via the same UI Policy actions, or leave them as not mandatory - realizing either option is misleading from a UX perspective as both variables are not mandatory, it's just a visual indication. To enforce that one of the variables is populated you would use an onSubmit Catalog Client Script. In pseudocode, if Safe Updating = Add User to Safe, and Standard User Role is blank, and Safe Manager Role is blank, show an error message and prevent the form submission. Give the script a shot and let me know if you get stuck on the syntax.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:42 PM
Hi Brad,
Thats will be a great move, can you help me with the code plz.
Best Regards,
Rafmine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:51 PM
Hi @Community Alums ,
Can you try something like this, please use proper backend names of the variable
function onSubmit() {
//Type appropriate comment here, and begin script below
var abc = g_form.getValue('add_user_safe');
var stdRole = g_form.getValue('standard_user_role');
var safeMgrRole = g_form.getValue('safe_manager_role');
if(abc == 'true' && stdRole == '' && safeMgrRole == ''){
alert('Kindly fill the Standard User Role Value & Safe Manager Role Value');
return false;
}else{
return true;
}
}
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 08:41 PM - edited 11-08-2023 08:49 PM
Hi Danish,
Thank you for replying to my post, appreciate it...
My scenario is that I have push user to at least fill one variable value.