- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 09:00 AM
Hi,
I have a catalog Item that return a list of Knowledge article from a particular Knowledge base in a Reference variable.
Current configuration :
Current configuration
OOB, the list will show the articles the user can READ.
Instead, we want to only show the articles the user can Contribute (edit).
I changed the Reference qualifier to "Advanced" and tried a few thing without success.
- I tried to call the "canWrite"' function from "KBKnowledge" script include directly into the qualifier.
- I tried to encapsule the same "canWrite"' function in an client callable script include where I try do a glide record and return a list of KB sys_id.
Every time my list is empty. (But not sure I implemented previous solutions correctly)
Would you have some suggestion ?
Thank you !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 12:38 PM
I haven't tried it myself but this is probably the approach you need to use in order to engage some more powerful server side logic in your reference qualifier by using a script include.
https://www.servicenow.com/community/developer-forum/need-a-canwrite-reference-qualifier/m-p/2116327
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 12:38 PM
I haven't tried it myself but this is probably the approach you need to use in order to engage some more powerful server side logic in your reference qualifier by using a script include.
https://www.servicenow.com/community/developer-forum/need-a-canwrite-reference-qualifier/m-p/2116327
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 04:38 AM - edited 06-14-2024 04:45 AM
Hi Daniel,
Thank you for your suggestion.
I had try this approach without success, but with your link I was able to identify issue within my script include !
Short answer :
It works now, so I'll accept your message as solution !
Long answer :
The knowledge base I'm looking at contain more than 20k articles, so evaluating each article for canWrite permission is not efficient and not a viable solution for my need. (long loading time every time I'm looking at the list)
But for someone wanting to evaluate a smaller table it could totally work.
Here is the code I used, so other people can adjust it to their need.
Script include :
var myScriptInclude = Class.create();
myScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCanWriteArticle: function() {
var result = 'sys_idIN';
var kb = new GlideRecord("kb_knowledge");
kb.addEncodedQuery('kb_knowledge_base=************^language=en^workflow_state=published');
kb.query();
while (kb.next()) {
if (kb.canWrite()) {
result = result + kb.sys_id + ',';
}
}
return result;
},
type: 'myScriptInclude'
});
Reference Qualifier :
javascript:new myScriptInclude().getCanWriteArticle()
EDIT : For reference qualifier : ":" -> ":"
I don't know with it's interpretated in the code sample