- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 08:48 AM
Hi everyone,
A while back we implemented a custom reference field to the Group table on our Knowledge article templates and because we only had the one KB, the reference qualifier was simple. Now we're adding a second knowledge base and I need a dynamic reference qualifier that filters the available options based on the value of the kb_knowledge_base field.
The problem that I'm having is that all of the examples I've found for Dynamic and Advanced reference qualifiers is that they all use the same simple example, javascript:"company=" + current.company
Basically what I want to do is evaluate the kb_knowledge_base field, and if the value is KB1, I want to show Groups where type=X, and if the value is KB2, show Groups where type=y.
Should I use a dynamic filter for this, or a script include? Does anyone have any examples I might look at?
Thanks for any guidance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 06:15 AM
You might be able to use current in this script include - try to decipher this
https://snprotips.com/blog/2019/12/18/can-script-includes-use-the-current-variable
Otherwise, change your reference qualifier to something like this
javascript:new u_KB_Utils().FilterKBApproverGroup(current.kb_knowledge_base);
then change the function declaration line in the script include and comment out the var kb line
FilterKBApproverGroup:function(kb) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 06:11 AM
can you paste the code so so that we can see where is it showing undefined.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 12:51 PM
Change your answer lines to
answer.push(gr.sys_id.toString());
and the return lines to
return 'sys_idIN' + answer.join(',');
If you're still getting unexpected results, you can add some gs.info lines to see what you're getting as the script runs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 05:40 AM
Thanks for the suggestion. I'm getting the same results, but I took your advice about the gs.info lines. The very first one I added is to return the value of the KB variable and the log is showing it is undefined... though, I'm not sure why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 06:15 AM
You might be able to use current in this script include - try to decipher this
https://snprotips.com/blog/2019/12/18/can-script-includes-use-the-current-variable
Otherwise, change your reference qualifier to something like this
javascript:new u_KB_Utils().FilterKBApproverGroup(current.kb_knowledge_base);
then change the function declaration line in the script include and comment out the var kb line
FilterKBApproverGroup:function(kb) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 06:31 AM
That got it! Thanks a million.
And thanks to everyone else as well for your time and suggestions.