user criteria based on city

jean-pauldehaas
Tera Guru

Hi,

 

im trying to create a user criteria based on the users city, i created this script but the catalog item doesnt show up for users with this city:

 

answer = checkLocation();

function checkLocation() {

    var userRec = new GlideRecord('sys_user');
    userRec.get(user_id);
    var userCity = userRec.city; // give correct field name here
    if (userCity == 'Katowice') {
        return true;
    } else {
        return false;
    }
}
3 REPLIES 3

Siddhartha Gaba
Tera Contributor

Your script logic is generally correct, but the comparison is case-sensitive. If it's stored as 'katowice' or 'KATOWICE', it will fail.

Sandeep Rajput
Tera Patron
Tera Patron

@jean-pauldehaas Your script seems okay, did you check if the city field for the users you are testing with is having Katowice value. The script will return false if the city field is not populated on the user record or if the city name is different.

hi i fixed it already the user_id was the issue