Knowledge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 04:18 AM - edited 01-01-2025 09:54 PM
Hello ,
How to write script in user criteria so that if their is an article in German language then the knowledge author and owner of that article can view the article irrespective of whatever is their language?
if (userGR.preferred_language == 'de'|| current.u_owner == gs.getUserID() || current.author==gs.getUserID()) {
return true;
}
this script is partially working
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:12 AM
For example , KB105607 is in German Language .
Abel's preferred language is German, so she is able to view KB105607.
Although Ankur is the owner of KB105607 he is not able to view it as his preferred language is English , so it allow this I have written below script,
var userGR = new GlideRecord('sys_user');
userGR.get(user_id);
if (userGR.preferred_language == 'de'|| current.u_owner == gs.getUserID() || current.author==gs.getUserID()) {
return true;
}
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:16 AM
update as this
var userGR = new GlideRecord('sys_user');
userGR.get(user_id);
if (userGR.preferred_language.toString() == 'de') {
answer = true;
} else if (current.u_owner == user_id || current.author == user_id) {
answer = true;
} else
answer = false;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:20 AM
still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:32 AM
Did you debug and add logs?
please share your debugging analysis
are you sure the field name u_owner is correct?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:34 AM
Yes the field names are correct and also used debugging but else if is not getting executed