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:40 AM
it won't work as you don't have access to current object and hence cannot determine the Owner or Author
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 06:00 AM
what is the solution then ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 05:42 AM
You persist in NOT copying correctly the suggestions.
You keep writing == gs.getUserID() while community members keep writing == user_id.
You only correct the 1st occurrence, but all must be corrected.
In User Criteria script - as specified in the comments for a new User Criteria script, one must not use gs.getUserID(), one must use user_id. Otherwise the check will be done against the user owning the current session, which might not be the user you expect to be. For sure it will render the User Criteria diagnostic tool useless.
Also one must be careful when testing the User Criteria, those are cached on login (or impersonation), so after each change a cache flush is advisable. Are you flushing the cache before each test run?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 06:31 AM
Corrected but it is still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 08:43 AM
Can you run the User Criteria Diagnostic over the article and post a screenshot of the result?
Example: