- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 09:47 AM
Hello!
I have a variable set that I'd like to make visible to only those with the a specific role assigned. I've tried various combinations of UI Catalog Policy and Catalog Client Scripts looking at the variable set (preferred setup if possible for ease of re-use) and a Catalog Item, but the best I've been able to accomplish is making the question itself mandatory/non-mandatory. I'm using versions of (onCondition also having been changed to onLoad and the variable_set also swapped out to the specific variable_name):
function onCondition() {
if (g_user.hasRole('role')) {
g_form.setDisplay('variable_set', true);
g_form.setMandatory('variable_name', true);
}
}
The variable name is Mandatory if the variable set is visible and has two items assigned to it that are visible based on out-of-the-box Catalog UI Policy setup. The variable_name itself is set up as non-mandatory since that will override the scripting to make it appear regardless.
Any help is greatly appreciated.
Thank you,
Erik Nelson
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 10:11 AM
Hi Erik,
For your requirement please use the below onLoad Catalog Client Script on the particular Item. It's working in my instance successfully. Also please make sure that no other Catalog Client Script or UI Policy should override this one.
function onLoad() {
if (!g_user.hasRole('admin')){
g_form.setDisplay('common_comments', false);
g_form.setMandatory('input', false);
}
else{
g_form.setDisplay('common_comments', true);
g_form.setMandatory('input', true);
}
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 10:03 AM
You are saying that the variable name is not going to be mandatory, is it correct?
show the screen shot of your catalog item.
check is there any catalog client script or ui policies overriding also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 10:07 AM
The variable set/variable name should only be visible and mandatory if the "role" requirement role is met. I have managed to turn on/off the mandatory piece using a variant of the script above, but not the visibility. Ideally, I'd like the policy to be part of the variable set so that I can create it once and re-use since this will be on multiple items. Currently, the variable set and intial variable name are non-mandatory
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 10:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2017 10:11 AM
Hi Erik,
For your requirement please use the below onLoad Catalog Client Script on the particular Item. It's working in my instance successfully. Also please make sure that no other Catalog Client Script or UI Policy should override this one.
function onLoad() {
if (!g_user.hasRole('admin')){
g_form.setDisplay('common_comments', false);
g_form.setMandatory('input', false);
}
else{
g_form.setDisplay('common_comments', true);
g_form.setMandatory('input', true);
}
}
I hope this helps.Please mark correct/helpful based on impact