Tanushree Maiti
Tera Patron

Hi @swatis22 

 

  1. Create a onLoad Ctalog Client script
  • Navigate to System Evolution > Client Scripts and click New.
  • Set the Table to your target table
  • Set the Type to onLoad

 

function onLoad() {

    var targetGroupSysId = '<YOUR_GROUP_SYS_ID>';

        var ga = new GlideAjax('GroupUtils');

    ga.addParam('sysparm_name', 'isUserInGroup');

    ga.addParam('sysparm_group_id', targetGroupSysId);

    ga.getXMLAnswer(function(response) {

      var answer = response.responseXML.documentElement.getAttribute("answer");

         if (answer == 'false') {

            g_form.removeOption('u_dropdown', 'value1_to_hide'); //Replace with your drop down field

            g_form.removeOption('u_dropdown', 'value2_to_hide');

        }

    });

}

 

2. Create a Script include

  • Navigate to System Definition > Script Includes and click New.
  • Set the Name to GroupUtils 
  • Check the Client callable box

 

var GroupUtils = Class.create();

GroupUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

        isUserInGroup: function() {

        var groupId = this.getParameter('sysparm_group_id');

        var userId = gs.getUserID();       

        var gr = new GlideRecord('sys_user_grmember');

        gr.addQuery('group', groupId);

        gr.addQuery('user', userId);

        gr.query();       

        return gr.hasNext();

    },   

    type: 'GroupUtils'

});

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti