Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

User Criteria for AMER region

Rahul Raja Sami
Tera Guru

Hi, this is my script

(function() {
   
    var userId = gs.getUserID();
    
    var gr = new GlideRecord('sys_user');
    gr.addQuery('sys_id', userId);
    gr.query();
    
    if (gr.next()) {
        if (gr.u_region == 'AMER') {
           
            return true;
        } else {
           
            return false;
        }
    } else {
      
        return false;
    }
})();

 

not sure why it is not working. Please check and tell.

1 ACCEPTED SOLUTION

(function() {
   
    var userId = gs.getUserID();
    
    var gr = new GlideRecord('sys_user');
    gr.addQuery('sys_id', userId);
    gr.query();
    
    if (gr.next()) {
        if (gr.u_region == 'AMER') {
           
            return true;
        } else {
           
            return false;
        }
    } else {
      
        return false;
    }
})();

 

this is working, thank you for the assistance.

View solution in original post

7 REPLIES 7

(function() {
   
    var userId = gs.getUserID();
    
    var gr = new GlideRecord('sys_user');
    gr.addQuery('sys_id', userId);
    gr.query();
    
    if (gr.next()) {
        if (gr.u_region == 'AMER') {
           
            return true;
        } else {
           
            return false;
        }
    } else {
      
        return false;
    }
})();

 

this is working, thank you for the support.

@Rahul Raja Sami Isn't this the same script which you posted in the question?

yes, I suppose. Not sure why it didn't work yesterday. But now it is working fine.