variables 'city' and 'state' should be visible to 'service' group member in catalog item

Purushotham9963
Tera Contributor

variables 'city' and 'state' should be only visible to 'service' group members in catalog item, need to be hidden for all users

how can i achieve this 
i saw some client script and script include and business rules but did not work , is this possible through catalog client script ? 

 

 

Thanks in advance 

6 REPLIES 6

Viraj Hudlikar
Giga Sage

Hello @Purushotham9963 

 

Please check this thread which will help you

Solved: Make Variables visible for certain group members - ServiceNow Community

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Purushotham9963 

You have to write a catalog client script

1. Create Script Include with a method - to check if logged in user is member of the group or not.

Make Sure Client Callable is checked to true.

groupMemberCheck: function() {
        var grp = this.getParameter('sysparm_group');
        return gs.getUser().isMemberOf(grp);
},

 

 2. Use below in your client script, OnLoad or OnChange according to your requirement.

    var ga = new GlideAjax('Scriptincludename');
    ga.addParam('sysparm_name', 'groupMemberCheck');
    ga.addParam('sysparm_group', g_form.getValue('service'));
    ga.getXML(groupMemberCheckXML);


function groupMemberCheckXML(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    if (answer == 'true') {
//add logic here
       }
}

 

 

You cannot acheive this with BR's as this is a catalog form.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

@Purushotham9963 

2 ways to handle this

1) use onLoad client script + GlideAjax and check if logged in user is member of that group. if not then hide

OR
2) give that service group some unique role and then give that role in the Persmissions tab under those 2 city and state variable. no scripting required

Only users with that role will see that variable during catalog form submission

AnkurBawiskar_0-1737443100418.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Purushotham9963 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader