12 Replies · Latest reply on Jan 25, 2017 3:26 PM by kkim

    How to hide variable based on logged in user and user field

      I need to hide a variable if the logged in user's employee number field is blank. I tried a few methods using a catalog client script but I'm not able to use the g_user function. The below is what I tried. This is in a catalog client script with the variable set specified. Would I need to create a script include to pull the current logged in user?

       

      function onLoad() {
      
      
        var id = g_user.userID();
        var gr = new GlideRecord('sys_user');
        gr.addQuery('sys_id',id);
        gr.addQuery('employee_number');
        gr.query();
      
        if (employee_number) {
        g_form.setDisplay('charge_method', true);
        } else {
        g_form.setDisplay('charge_method', false);
        }
         
      }