Make a field not mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:59 AM
Hi Everyone,
I have a requirement to make fields mandatory on the ritm level but only mandatory for a group of users completing the form? Below are the details of the process
The variables are hidden on the catalog item.
If the manager determines additional information is needed then the variables are required by a yes/no ui policy
The problem is the manager doesn't need to complete the form, so I need to exclude her and others from seeing them as required.
I realize the best way to achieve this is probably with a UIPolicy but I'm struggling on how to exclude the manager/group from seeing the variables as required.
Below is the script I have so far but not sure if there is a better way to do this or if its possible?
function onSubmit() {
//Type appropriate comment here, and begin script below
g_form.setMandatory('field_name',false);
}
Thanks so much for any feedback you have!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 09:20 AM
I'm not sure I understand your suggestion. I attempted the solution by @Samaksh Wani but unfortunately the variables are now required for everyone; regardless of group and it should only be required for the group members if the variable additional information is yes. I'm not very good with scripting and not familiar with Ajax call. Can I get your help further?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:07 AM
I also tried the following client script and now objectives is not required at all..😢
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:48 AM
Good news I got the script to almost work and just need a tiny bit more help. Below is the onload client script I used and when a member of service desk is selected the objective variable is not required. However when a member of Project management with Role PM the objective variable is required. That part is great.
My last questions is, the variable objective should only be required for the role PM if..
variable additional information = yes
Can I get help adding that last part??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:59 AM
Hello @Gemma4
function onLoad() {
var role = g_user.hasRole('pm');
var info =g_form.getValue('additional_information');
if( role == true)
{
if(info=='yes'){
g_form.setMandatory('objectives',true);
}
else{
g_form.setMandatory('objectives',false)
}
}
else
{
g_form.setMandatory('objectives',false);
}
}
Here is your additional script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 11:02 AM
Try this:
var ynAddtnlInfo = g_form.getValue('<additional info variable name');
if (ynAddtnlInfo == 'yes'); {
//do the "yes" part of it
}
else {
//do the "no" part of it
}