Hide Multiple choice option for all but specific group

dagarson
Tera Guru

Hello I have a catalog item where I am trying to hide a multiple choice value from all users who access the form unless they are part of a specific group. However the script I am trying to run isnt working.

function onLoad() {
 
    var targetGroup = '09745cc9c3302200e7c7d44d81d3ae6f';

    // Check if the current user is a member of the target group
    if (!g_user.isMemberOf(targetGroup)) {
        // Remove "op_3" option if the user is not a member of the group
        g_form.removeOption('choice', 'op_3');
    }
}

Does anyone see an issue with this approach? It seems like it should be a pretty simple script. 

 

Thank you

1 ACCEPTED SOLUTION

Bhavani Shankar
Tera Guru

Hello @dagarson ,

 

I doubt if isMemberOf is even a method of g_form object. isMemberOf is a method available in GlideUser object which works on the server side. 

 

For your case I think you should try and create a client callable script include and do your validation there.

 

Please do leave a thumbs up if my response helped you

 

 

Regards,
Bhavani Shankar
Linked In

View solution in original post

5 REPLIES 5

Bhavani Shankar
Tera Guru

Hello @dagarson ,

 

I doubt if isMemberOf is even a method of g_form object. isMemberOf is a method available in GlideUser object which works on the server side. 

 

For your case I think you should try and create a client callable script include and do your validation there.

 

Please do leave a thumbs up if my response helped you

 

 

Regards,
Bhavani Shankar
Linked In