Advance view rules script for knowledge
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2025 08:52 AM
I'm working on a View Rule in ServiceNow where I need to display the "People_Zone_View" specifically when the knowledge base is "IT", and fall back to the default view for all other cases. I tried using dot-walking with current.kb_knowledge_base.name but it doesn't seem to be working as expected. Could you help me understand the correct approach for referencing the knowledge base name in a View Rule, or suggest a better way to implement this logic?
Here is the code:
(function overrideView(view, is_list) {
var answer = view; // Default to the current view
// Access the knowledge base record
var kb = new GlideRecord('kb_knowledge_base');
kb.addQuery('sys_id', current.kb_knowledge_base);
kb.query();
if (kb.next()) {
// Check if the knowledge base name is "IT"
if (kb.name == "IT") {
answer = "People_zone_view";
}
}
return answer;
})(view, is_list);
Can anyone help me to solve?
Can anyone help me to solve?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2025 02:57 AM
I didn't use the script later as view rule condition was enough to do it bro.