Knowledge

harry24
Tera Contributor

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 

 

23 REPLIES 23

@harry24 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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;

harry24
Tera Contributor

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;

@harry24 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

yes you are correct