Make Variables visible for certain group members

Rowella Montell
Tera Contributor

Hi All,

I was given a task to create a new catalog item and one of the requirements is that some variable fields should be only visible to a certain group members. I'm trying to create a script in the Catalog UI Policy to do this, what I need to do is to get servicenow read if the current logged in user is a member of a certain group and if he/she is then some variable fields should be visible to them. Can anyone help as to how I can achieve this? I'm still new to this so I'm not really sure how this should work.

 

Thank you!

1 ACCEPTED SOLUTION

Okay this is what it should have returned to you.

Now can you make sure you have given the correct variable names in your script. It should be the backend Name of the variable.

Can you share screenshot of your variable form which shows the name to make sure that has been entered is correct.

 

Like for example in my case, my current logged in user is part of two groups as shown below:

find_real_file.png

 

Now in my script I am checking if User is part of "Team Development Code Reviewers" queue then I am hiding my Variables 1 and Variables 2

find_real_file.png

 

This hides both my Variables on the form. For reference I have attached my Variable form screenshot as well below to make sure the name added to your script is the name highlighted:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

19 REPLIES 19

Hi @shloke04 ,

 

It seems like it's returning all of the groups the user is a part of:

find_real_file.png

Okay this is what it should have returned to you.

Now can you make sure you have given the correct variable names in your script. It should be the backend Name of the variable.

Can you share screenshot of your variable form which shows the name to make sure that has been entered is correct.

 

Like for example in my case, my current logged in user is part of two groups as shown below:

find_real_file.png

 

Now in my script I am checking if User is part of "Team Development Code Reviewers" queue then I am hiding my Variables 1 and Variables 2

find_real_file.png

 

This hides both my Variables on the form. For reference I have attached my Variable form screenshot as well below to make sure the name added to your script is the name highlighted:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi @shloke04 

 

I think it did worked, I just impersonated a user that is part of the "Hardware" group and it did hid the variables. Although what I need is to make some variable visible to let's say the members of "Hardware" group and if the logged in user is not a member of the said group then it should be hidden. What I just did is set the 2 variables hidden first and if the logged in user is a part of the defined group, then the variables will be set to true instead of false. Although I need to do this same thing in a Multi-row variable set. Do you think it should work there as well?

 

Also THANK YOU SO MUCH FOR YOUR HELP! I'm really having a difficult time figuring this out as I'm still learning about the scripts. I really appreciate your time helping out! 🙂 

find_real_file.png

Nope unfortunately this is not possible with Multi Row Variable Set . Please refer to below HI Article from ServiceNow:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0960829

 

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Jay N
Tera Contributor

Solution helped me for one of the similar requirement.

Thanks Alot Shloke.