pulling Region is corporate information

Jean-Paul de Ha
Tera Contributor

i have a catalog item which contains a variable corporate_access (type: Yes/no) , what im trying to achieve is when the logged in user who is going to request the catalog item is from a corporate region it should show the corporate_access variable but if the user is not it should be hidden.

on the u_regions table there is a checkbox (u_corporate_region) which determines if its a corporate region or not.

 

i created a script include and a client script, what am i doing wrong here ?

Client script:

JeanPauldeHa_0-1725452159240.png

 

Script include:

JeanPauldeHa_1-1725452192643.png

 

 

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@Jean-Paul de Ha Your script in the script include is incorrect due to which your code is crashing on line number 8 of your script include.

 

I am assuming you have a u_region reference field on your sys_user record and you would like to check if it is a corporate region or not. You can check the same via following script.

 

getRegion: function() {
    var glideUser = new GlideRecord('sys_user');
    var answer = '';
    if (glideUser.get(gs.getUserID())) {
        if (glideUser.u_region.u_corporate_region == 'true') {
            answer = 'true';
        } else {
            answer = 'false';
        }

        return answer;
    }
}

 

Hope this helps.

@Sandeep Rajput no there is no region field on the sys_user record, the u_regions table has a field called u_corporate_region thats the field that determines if its a corporate region or not