- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 10:00 AM
Hi All,
I have written this User Criteria on article Level this script in executing and its going to inside the IF condition but is not working as expected Please help me to resolve this issue
checkRegion();
function checkRegion() {
var s = gs.getUser().getRecord().getValue('u_country');
gs.addErrorMessage(s);
if(s == "IND")
{
answer = true;
}
else
{
answer = false;
}
User Criteria :-
KB Article
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2018 02:08 PM
Hi Ramesh,
Can you please try the following code in your user criteria:
answer = false; // Default to false
var userRec = new GlideRecord("sys_user");
if (userRec.get(gs.getUserID())) {
var s = userRec.getValue('u_country');
gs.addErrorMessage(s);
if(s == "IND") {
gs.addInfoMessage("My Country is: " + s);
answer = true;
}
}
Let me know if it worked for you.
Brent
P.S. Please mark as correct if this information helped you so the rest of the community can benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2018 08:43 PM
The advanced user criteria is expecting the "answer" variable to be set to true or false. You had "answer" wrapped in your function so all that was returned was true or false not answer = true or false.
You probably could have done the following to get the same result:
answer = checkRegion();
function checkRegion() {
var rightCountry = false; // Default to false
var userRec = new GlideRecord("sys_user");
if (userRec.get(gs.getUserID())) {
var s = userRec.getValue('u_country');
if(s == "IND") {
rightCountry = true;
}
return rightCountry;
}
}