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:22 AM
your first part is wrong about preferred_language
use this
var rec = new GlideRecord('sys_user');
rec.get(user_id);
if (rec.preferred_language == 'de'|| 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 04:28 AM
This is my script but it is not working , what it does is it gives all owner and authors access to all kb's.
var userGR = new GlideRecord('sys_user');
userGR.get(user_id);
if (userGR.preferred_language == 'es'|| 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:31 AM
what does it mean?
How to write script in user criteria so that if their is an article in German language
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:35 AM - edited 12-31-2024 04:35 AM
Hello Ankur,
I have created an User Criteria called German Language Users and added it to can read field of Knowledge article.
So now if their is a KB called KB190256 in German Language and can read is set to German Language users , so now all the users whose language is German should be able to see this article , as well the owner and author of this article should be able to view it even if their language is not german . so I have written below script which is not working
var userGR = new GlideRecord('sys_user');
userGR.get(user_id);
if (userGR.preferred_language == 'es'|| current.u_owner == gs.getUserID() || current.author==gs.getUserID()) {
return true;
}
return false;
Thanks