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-25-2023 11:37 AM
OK, I tested this in my developer instance.
Catalog UI Policy:
Then I turned the script on and set the true script to:
Hope that works for you...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 10:05 AM
Hi @cgedney
I've tested again in my pdi and still no luck. I checked with the business and doesn't sound like they want to utilize my workaround with the extra field. Below is a summary of everything I've attempted in case I'm missing something so small. Thank you for all the help, please let me know if you have any ideas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 11:12 AM
Hey Gemma4,
OK, you need to de-activate the Catalog Client Script, since the UI Policy is doing the work now.
I am not 100% sure I understand the criteria you are asking for. Originally, you said that if the user has the pm role and they select Yes to the additional Info, then the objective is mandatory. Everything else, the objective is not mandatory. Is that correct?
If so, then this is what I have:
I created a catalog item with these variables:
I then created a Catalog UI Policy:
And on the script tab:
function onCondition() {
var role = g_user.hasRole('pm');
g_form.addInfoMessage("Role: " + role);
if (role == true) {
g_form.setMandatory('objectives', true);
}
else {
g_form.setMandatory('objectives', false);
}
return true;
}
Let me know if that works.