- 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-01-2018 08:54 PM
Hi Michael,
Sorry for late reply, i have tried the script and this script is returning correct country value but its not working as expected.
This is the code i used in "Can Read" Condition articel level
checkRegion();
function checkRegion() {
var answer = false; // Default to false
var userRec = new GlideRecord("sys_user");
userRec.get(gs.getUserID());
var s = userRec.getValue('u_country');
gs.addErrorMessage(s);
if(s == "IND")
{
answer = true;
}
return answer;
}
========
IND User
USA User
- 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:11 PM
HI Brent,
I use the above code please find the result below
If I use this user criteria in "Can Read" condition means Both USA and IND user unable to view the article
If I use this user criteria in "Cannot Read" condition means Both USA and IND user able to view the article
and i created two user criteria and used in both "Can Read" and "Cannot Read" means Both USA and IND user unable to view the article
Still its making confusion
User Criteria:-
USA User : -
IND User :-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2018 08:20 PM
Hi Ramesh,
Can you please confirm that you have put the code in exactly as I specified? It should not be wrapped in the checkRegion() function that you originally had. Can you repost the code as it is when you retested.
Thanks,
Brent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2018 08:32 PM
HI Brent,
Thank you so much for your help its worked now with your code what i expected
If possible please explain what i did mistake in my previous original code with "checkRegion() function" i will help for future
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;
}
}
Thanks
Ramesh R