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

Deepak Kumar5
Kilo Sage

Try below in your reference qualifier. If this will not work then update your Script include for line

answer.push(gr.group.toString());

answer.push(gr.sys_id.toString());

 

 

javascript: var kb = current.kb_knowlege_base;
var answer='';
var gr = new GlideRecord('sys_user_group');
if (kb == '2393589edb2b405091d1c1911596193e'){
gr.addEncodedQuery('typeLIKE458de4f067671300dbfdbb2d07415ad6^active=true');
gr.query();
while(gr.next()){
answer+=gr.sys_id + ",";
}
else if (kb == 'bb0370019f22120047a2d126c42e7073'){
gr.addEncodedQuery('typeLIKEd879e93d1b255c1016a742e2cd4bcb0d^active=true');
gr.query();
while(gr.next()){
answer+=gr.sys_id + ",";
}
"sys_idIN" + answer;