User criteria check

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2022 01:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2022 02:14 AM
I might have misunderstood your requirement here, but if you are really just trying to understand if the logged-in user matches *any* user criteria, then the following should work:
var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID()); //Returns an array of any or all user criteria's matched by the logged in user
if (allCriterias.length > 0){
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2022 02:23 AM
Hi Glenn,
Use GgetAllUserCriteria. You will be getting a list of user criterias. If it's returning any value, it means user is part of any user criteria.
I understand your requirement is to check if the user is in at least any one of the user criteria. Then the above solution can be used

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2022 02:37 AM
Hi,
The problem I am facing is that I am trying to disable the download of attachments via link. And I am trying to use an ACL to limit this. Because it is a security concern if say a user has access to the article, copies the attachment link, and sharing it to a person that shouldn't be accessing it. The script include that I am using is the OOTB AttachmentSecurity but it is extended so I can edit the parameters.
Using a direct link overrides this. It can be done on ACL level by stating the role the user should have. However, as most know, the amount of roles would be extremely long. Hence using user criteria on the kb_knowledge (this is the table that I want to limit access to) would be preferred.
/Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2022 03:11 AM
So if you want to check if a user is in a specific User Criteria you can use this?
var userCritieriaID = 'fb1166d64fff0200086eeed18110c7ab'; //example user criteria sys_id
var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID()); //All logged-in users User Criteria
if (allCriterias.indexOf(userCritieriaID) > -1){
return true;
}