Dynamic/Advanced reference qualifier examples?

Chad7
Tera Expert

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.

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

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) {

View solution in original post

10 REPLIES 10

can you paste the code so so that we can see where is it showing undefined.


Raghav
MVP 2023

Brad Bowman
Kilo Patron
Kilo Patron

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.

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.

Brad Bowman
Kilo Patron
Kilo Patron

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) {

That got it! Thanks a million.

 

And thanks to everyone else as well for your time and suggestions.