How to Restrict related only for particular conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-08-2025 08:32 PM - edited ā05-08-2025 10:00 PM
Hi
Can some one please help on this
on the Issue form there is one related list Entities currently showing class, description columns client expecting more columns to be add but those columns should be visible only if entity table (on the entity form there one table called business process)for others remains the existing columns
how can this achieve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-08-2025 08:59 PM
You can achieve it by doing the following:
1. Create Multiple Views:
-navigate to the List Layout for the related list table
-create different views (e.g., Default, Business_Process_View).
-Add the appropriate columns to each view.
Then 2. Use Client Script to Dynamically Switch Views:
function onLoad() {
var entityType = g_form.getValue('entity_type'); // Replace with the actual field name
if (entityType === 'business_process') {
// Switch to the Business Process view
setRelatedListView('Entity', 'Business_Process_View');
} else {
// Default view for other entities
setRelatedListView('Entity', 'Default');
}
}
// Helper Function to Change Related List View
function setRelatedListView(relatedListName, viewName) {
var relatedList = GlideList2.get(relatedListName);
if (relatedList) {
relatedList.setView(viewName);
relatedList.refresh();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-08-2025 09:21 PM
HI @folusho
Thanks for Response but we don't have 2 views instead of creating new view can you please suggest is there any other way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-08-2025 09:29 PM
Unfortunately, I don't know of any other way than to use List views.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-08-2025 09:55 PM
you can have multiple views and then switch the view in that related list based on form load
No other way.
See if the script shared by @folusho works for you and share the updates.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader