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

amolpawar
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

amolpawar
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

Hi @Dr Atul - 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 @Dr Atul - 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