How to restrict the option in reference filed on the selection of choice in another field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 04:38 AM
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 04:53 AM - edited 06-26-2025 05:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 05:59 AM
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"
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 09:42 PM
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 04:59 AM
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'.