How to restrict the option in reference filed on the selection of choice in another field

vinitaraico
Tera Contributor

Hi Team,

 

we have multiple active knowledge base 

I have created a new field on kb_knolwedge form.  On selection of this new filed ,I am populating value in knowledge base filed .

 

new field is "End User Article" Type -choice ->Yes/No

existing field  "Knowledge base " is a reference field -  also There is a dynamic filter (Get Default Knowledge Base) to get all  active knowledge bases

 

Now on selection of Yes  ,I am setting  knowledge base field value   "abc"

On selection of No - Knowledge base is showing all active knowledge bases ,including "abc" knowledge base ,How can I remove it from the list? I should not want "abc" to visible  when  selection of "No"

 

 

 

 

 

 

6 REPLIES 6

Ehab Pilloor
Mega Sage

Hi @vinitaraico,

 

You will need script include and advanced reference qualifier on your custom field.

 

Script Include Name: GetFilteredKnowledgeBases
Client Callable: False

var GetFilteredKnowledgeBases = Class.create();
GetFilteredKnowledgeBases.prototype = {
    initialize: function () {},

    getKbs: function (endUserArticle) {
        var query = "active=true";

        if (endUserArticle == 'Yes') {
            query += "^sys_id=a1b2c3d4e5f67890123456789abcdef0";  // add sys id of abc
        } else {
            query += "^sys_id!=a1b2c3d4e5f67890123456789abcdef0"; // add sys id of abc
        }

        return query;
    }
};

Its better you store the sys_id of abc in a system property, call it in the script and add where i have mentioned to add. 

 

Advanced ref qualifier:

javascript: new GetFilteredKnowledgeBases().getKbs(current.u_end_user_article)

Use the backend name for End User Article you have created in above script after 'current.'  

 

Regards,

Ehab Pilloor

Hi Ehab,

 

Thanks for reply ,I am not sure  why  need  advanced reference qualifier on  custom field.

My custom  field is a choice field "End user article"

 

vinitaraico_0-1750940969958.png

 

Eg. I have 3 active  knowledge base "abc" "efg" "hij"

When author select  " End user Article" is Yes - I am  setting Knowledge base to  "abc"  via client script

 

When author select "End user Article"  No - it is showing all active knowledge base including "abc"  ,I  only want to show "efg" "hij"

 

I can see there is a  dynamic filter  "Get Default Knowledge Base"  on Knowledge base filed which is calling OOTB Business Rule: knowledge functions IN the reference script  ,do I need to modify there

 

vinitaraico_1-1750942725269.png

 

 

 

 

Hi @vinitaraico 

 

it sounds to me like you just need a scripted UI policy to filter out the options that you would not like to see?

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Brad Bowman
Kilo Patron
Kilo Patron

I don't know if I'm following exactly, but it sounds like you'll want to add current as an argument in the script field of the dynamic filter, then modify the getDefaultKB script that is called to return only the results you want for each end user article yes or no - or whatever determines that 'abc' should not be seen when the value is 'no'.

BradBowman_0-1750939130751.png