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

Ankur Bawiskar
Tera Patron
Tera Patron

@harry24 

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.

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

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;

@harry24 

what does it mean?

How to write script in user criteria so that if their is an article in German language

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

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