Verify User Criteria using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 12:44 PM
Hi there
whats the simplest way to verify User Criteria when KB is searched using a script. GlideRecordSecure only applies ACL verification during query run time, how about checking User Criteria too while searching KB articles using script.
For example, script below searches all matching articles applying ACLs on it
getKnowledge();
function getKnowledge() {
//Query all active records from IT or HR type articles (custom fields) which are valid
var query = "workflow_state=published^u_knowledge_typeINIT,HR^active=true^metaLIKEbenefits^textLIKEholiday";
var kb = new GlideRecordSecure('kb_knowledge');
kb.addEncodedQuery(query);
kb.addQuery('valid_to', '>=', (new GlideDate()).getLocalDate().getValue());
kb.query();
gs.info('WDPR KB Search : Number of records found >>>>'+kb.getRowCount()); //prints matching records
while (kb.next()) { // verifies the ACL at this point of time with given GlideRecordSecure
//DO whatever
}
}
How the same script could be modified to add 'User Criteria Check on each article'? I know querying kb_uc_can_read_mtom table across each Knowledge Base may provide some info, but wanted a simplest API way to quickly verify like canRead() etc
thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2017 04:08 PM
Sashi,
What exactly is the business requirement for what you are trying to accomplish with the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2017 11:59 AM
Hi Adam
thanks for responding. The business requirements, is perform a search by script and get count on matching criteria. Say a User is performing a search using 'search string' across KB base, we need to return count of matching records in a script.
Now User ABC performs a count, uses Zing search to find matching records and count, script returns count. How to do we apply User Criteria that is defined across KB Articles at run time? If user ABC is trying, how to we enforce UC for each record returned in search
Sashi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2017 08:02 AM
Hi Sashi,
To clarify, this may be made easier by understanding that user criteria are not enforced on each article in the knowledge base. They are applied to the knowledge base itself. Searches honor the user criteria that are applied. As a user, I don't necessarily care what user criteria are applied.