Few catalog item should be hidden for netherland user

Nisha Mishra23
Tera Contributor

Hello 
We have requirement where few catalog item should be hidden for Netherlands user, so I have created one user criteria and wrote a script which is below it worked at that time but next day when I impersonate the same person who belong to Netherlands then it stopped working. I tried by clearing cache and cookies, but it is not working.  Is there any solution to resolve this issue.

answer = isUserFromNetherlands();

function isUserFromNetherlands() {
    var user = gs.getUser();
    var location = user.getLocation();
    var locationGR = new GlideRecord('cmn_location');
    if (locationGR.get(location.sys_id)) {
        var country = locationGR.getValue('country');
        if (country == 'Netherlands') {
            return true;
        }
    } else {
        return false;
    }

};
2 REPLIES 2

Community Alums
Not applicable

Hi @Nisha Mishra23 ,

Open related catalog item from maintain items.

Scroll down below and locate 'Not Available for' related list.

Click on create new which will open up new user criteria form.

SandeepDutta_0-1731938691315.png

 

Then in advance you can write script of your choice for evaluation and your case you want to hide it for all users from Netherlands then it can look like following:

SandeepDutta_1-1731938779210.png

 

 

var country = 'Netherlands'; //validate this value for Finland
var usr = new GlideRecord('sys_user');
usr.get(gs.getUserID());
if (usr.country == country) {
    retVal = true;
} else {
    retVal = false;
}

 


I have done that. I have added the criteria in Not available for. It did work for few hour but after that it stopped working.