We are currently experiencing intermittent login issues on Community.  The team is actively working on a fix.

User criteria check

Glenn Vattudal
Tera Expert
Hello. I am trying to use the user Criteria API to check whether a logged in user is actually in the criteria. The post I am using is: https://www.servicenow.com/community/developer-blog/usercriterialoader-api-to-evaluate-user-criteria... But I am curious as to use it since I do not want to check on a particular sys_id of a User Criteria but rather to see if the user is actually in any of the user criterias. For example: var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID()); var matchingCriterias = sn_uc.UserCriteriaLoader.getMatchingCriteria(gs.getUserID(), allCriterias); if (matchingCriterias == true){ return true; } Does anyone have any suggestions? Regards, Glenn
8 REPLIES 8

Hi Glenn,

 

So your requirement is to restrict somebody from using the knowledge article. Use the same script include and do an indexOf in the resulting array to check if the user is part of of the specific user criteria. This will be a check on user's user criteria in another user criteria for the knowledge articles

Not so much restricting the article. The problem is when we have an article that the user cannot see, all is well, BUT if he/she gets hold of the attachment link on the article the person can download it no matter if they can see the article or not.

Hi Glenn,

 

I got it. Not sure about this, but it's worth giving a try with 'g_form.disableAttachments()'. Will disable the button itself.

Can you give an example of the code to be used?