How to make a catalog item show different variables based on a group or role you are part of.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 06:55 AM - edited 04-23-2024 06:56 AM
Hey Everyone,
I have a need to change what a user sees on a catalog item based on a role or group membership. I am not too familiar with scripting in SN or business rules.
The use case is, We have a catalog item for laptop theft. We need this to be "available" for anyone to submit so our Helpdesk team can submit the request as the user so the workflow can auto populate the users CI info for their laptop. We do not want users themselves submitting this request however as they need to speak with the helpdesk to change their password. So we want some sort of script or BR that if a user clicks this catalog item, it shows them a message just stating they need to call User support. But if a user with ITIL role clicks it, they see all the variables.
What would be the easiest way to accomplish this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 10:31 AM - edited 04-23-2024 10:32 AM
Hi @arohm
This can be one possible solution
Create 2 items with same name
1)In 1 catalog item create all the variables and flow you needed and under related list
Available for - only itil users
2)Create 2nd as content item with same name
-Put the information that you want users to see
Available for - only users who have only snc_internal role
Not available for - itil users
Please mark my answer correct/helpful if it resolved you query.Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 01:25 PM
That is a good alternative and something i was looking at. I really prefer it to be a single item with a client script that hides based on role though if i could. I wrote a script but its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 07:48 PM
Hi @arohm ,
In that case try if this script works:
rite a onLoad client script:
function onLoad() {
if(!g_user.hasRole('itil')//if the user does not have the role itil
{
g_form.setDisplay('variable for non-itil user', true);//here your variable name will be the label that you created only for non-itil users
g_form.setDisplay('your variables',false);//continue to make all the other variables present in the form to display=false
}
else{
g_form.setDisplay('your variables',true);
g_form.setDisplay('variable for non-itil user',false);
}
}
Also note if you have made any field mandatory include code for mandatory to be false/true accordingly so that the display will work.
Please mark this comment as Correct Answer/Helpful if it helped you.Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 07:49 AM
So there are several fields that are mandatory on this form. Would the correct way to have this script mark them not mandatory be:
"g_form.setMandatory('variable, false);"
Or could i just do "g_form.setMandatory(false);" for the entire form?