Catalog Variable should be visible to one person or one group.

Atchutaram
Tera Contributor

Hi Experts,

Good Day!

                         I am trying to make one variable on catalog item to one particular person or one particular group.

For example: the variable name is Request type, this should be visible only to one user or one assignment group.

 

Could you please assist me with this.

 

Best Regards,

Atchut ram 

1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

There is also the possibility to set Permission on the variable.
You can add which roles  should have access to the variable, and give that role only to a specific group/person.

variable-permission.png

View solution in original post

5 REPLIES 5

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Atchutaram,

 

Please write a on load client script to check the user Id of the user and then check if it matches with your required user. You can also check if the logged in user is a member of required group.

and depending on the above condition show or hide the field.

Please let me know if you require script as well.

Please mark it as correct.
BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Hi nayan,

                    Could you please provide the script as well.

Hello @Atchutaram ,

Please use the below scripts to hide for user :

 

Write a display business rule to store the values in scratchpad:

 

(function executeRule(current, previous /*null when async*/) {

 

      // Add your code here

 

      g_scratchpad.isMemberOfITSAPECC = gs.getUser().isMemberOf('your group name');  //to check member of group

 

      g_scratchpad.myTest = gs.getUserID() == 'sys_id of user';  // to check logged in user

 

})(current, previous);

 

Then call the above BR in client script:

 

function onLoad() {

      var myVariablesAreReadOnly = true;

      if((g_scratchpad.isMemberOfITSAPECC ) // or you can also check for logged in user same as done here.

{

              myVariablesAreReadOnly = false;              

      }

      g_form.setReadOnly("variables.u_sap_short_description", myVariablesAreReadOnly);

     }

 

Please mark as correct if it helps.
BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Sagar Pagar
Tera Patron

Hi,

You can use the load client scripts.

Take a look at old thread -

Is there a way to hide/show a variable based on the current user's group? 

Hiding Catalog Item Variables based on Group Membership 

 

Thanks,
Sagar Pagar

The world works with ServiceNow