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 04:46 AM
the language to compare should be de and not es
var userGR = new GlideRecord('sys_user');
userGR.get(user_id);
if (userGR.preferred_language.toString() == 'de'|| current.u_owner == user_id || current.author== user_id) {
answer = true;
}
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 04:49 AM
yes that was typing mistake , it is not working
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 04:51 AM
Hello Ankur ,
The script works perfectly fine for checking german language users , but as I add author and owner script it gives access to all KB's to authors and owners
if (userGR.preferred_language == 'de') {
return true;
}
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:02 AM
if logged in user is German then they should see all irrespective of the author or owner?
if logged in user is not German then they should see articles only if they are owner or author?
Is my understanding correct?
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:06 AM
yes you are correct