Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to hide a few choice values- if logged in user belongs to a specific group

Amol Pawar
Tera Guru

Hi Experts,

 

I have a requirement like I have created a record producer. The first variable is a select box in which I have added 4 choices. I want to hide some choices if a logged-in user belongs to a group.

How can I achieve this?

 

Let me know if anyone has done similar to this requirement.

Regards,

Amol

1 ACCEPTED SOLUTION

Amol Pawar
Tera Guru

Hi All,

Thank you for your replies. I got the answer from the thread: 

https://www.servicenow.com/community/developer-forum/abstractajaxprocessor-undefined-maybe-missing-g...

 

Script Include:

var checkGroupMember = Class.create();
checkGroupMember.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    checkGroup: function() {
        var grp = gs.getUser().isMemberOf('DISCL - Reviewers');
        return grp;
    },

    type: 'checkGroupMember'
});
 
Client script:
function onLoad() {
    //Type appropriate comment here, and begin script below

    var ga = new GlideAjax('checkGroupMember'); // Script Include Name here
    ga.addParam('sysparm_name', 'checkGroup'); // Your Function Name here
    ga.getXML(callback);


    function callback(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert('Before if');
       

        if (answer == 'true') {
            alert('After if');
            g_form.removeOption('type_of_disclosure', 'Audits');

        }
    }
}

Thank you,

Amol

View solution in original post

12 REPLIES 12

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Amol Pawar 

Similar

 

https://www.servicenow.com/community/itsm-forum/show-hide-choices-on-field-depending-on-which-group-...

https://www.servicenow.com/community/developer-forum/restriction-to-choice-list-for-role/m-p/1961941

https://www.servicenow.com/community/hrsd-forum/how-to-hide-certain-choices-based-on-logged-in-users...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG ,

 

Thank you for your reply but I want to achieve this if the logged-in user belongs to a specific group, then I should be able to remove some options from choices of select box.

Could you please provide me the demo catalog client script for this?

 

Thanks in advance,

Amol

Hi @Amol Pawar 

 

Have a look here

 

https://www.servicenow.com/community/developer-forum/hide-question-choice-based-on-logged-in-user-be...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG  and @Ayushi12 ,

Below are my script include and client script, still not working for me.

Any suggestions?

AmolPawar_0-1705580024527.pngAmolPawar_1-1705580098211.png

 

Thank you,

Amol