User Criteria

harry24
Tera Contributor

Hello , 

 

I have user criteria set for knowledge articles . 

for example if german users than in script it checks if the users preferred language is german than it shows the article . 

 

Now the problem is say suppose their is a user Abel Tutor whose preferred language is English . Their is one article KB0015321 which has can read set to all german users . Now though abel tutor is owner of article but still he is not able to view it as his preferred language is english . How do I modify my script ?

@Anurag Tripathi  

Thanks 

7 REPLIES 7

How to dynamically set the addQuery()? Below is my script

(function checkLanguage() {
var userGR = new GlideRecord('sys_user');
if (userGR.preferred_language == 'de') {
return true;
}
return false;

})();

Juhi Poddar
Kilo Patron

Hello @harry24 

You Can try this logic:

  • Add a condition to check if the user is the author of current knowledge article 

 

    // Get the current user
    var userSysId = gs.getUserID();
    var user = gs.getUser();

    // Check if the user is the author of the article
    if (current.author == userSysId) {
        // Author can always view the article
        return true;
    }​

 

  • If Yes it returns true bypassing the user criteria check.
  • If No then add the existing user criteria logic

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

this is not working