How can we hide a field based conditions in Related list columns

Raj90
Tera Guru

Hello guys,

How can I hide a Size field from the related list view based on conditions?

For example:

1. If Size = "empty" in related list view, Then we don't see the size column in a related list. 

find_real_file.png

2. If Size = anything, Then we see the Size column in a related list.  -It's Working fine

find_real_file.png

Regards,

Raj

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

There's no out-of-the-box feature for this. You could mimic this thru scripting, removing/adding the column on the list. Note that it's just always having the column or not. So if you have a list with the field sometimes empty, sometimes filled, then probably you would just want that column.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

 

What kind of scripts can we use to hide columns in the related list tab

either ACLs or Client Script or UI policies or something else
could you please suggest me, thanks in advance

Krishna  Penaka
Tera Expert

Hi,

Raj

 

Hiding and Showing Related Lists

There are some built-in methods for showing and hiding standard related lists. Simply provide the table name of the related list you want to hide (or the ‘Related list’ field value from the list control in some cases). One limitation you’ll want to be aware of is that these methods hide the related list, but they don’t hide the tab if you’re using tabbed forms.

I’m using the ‘Affected CIs’ related list as an example in these scripts. Replace ‘task_ci’ below with the table name of your related list.

Hiding a Related List

g_form.hideRelatedList('task_ci');

Showing a Related List

g_form.showRelatedList('task_ci');
 
 
 
 
Regards ,
 
Krishna Teja
 

Community Alums
Not applicable

So what if some of the records contain a size values, some don't?
How would you show a table (so that it will look different from how it is shown usually) where some rows have that cell displayed, some don't?

On the other hand, if the visibility of the size column depends on the record in the form, you could create a view rule for the record and customize the related list for that view:

1. one form view where the size should be show and the related list will have a size column.
2. another form view where the size should not be shown and the relate list thus will  have no size column.

Looking at your examples you would define two views for the Request form: "Items with Size" and "Item without Size".
Than you would define two view rules:

- one that makes the form use the 1st view if the current request has a requested item child record that has size information and
- another that makes the form use the 2nd view if the current request has no requested item children that have size information.

Than you'd open requests for both views and you'd customize the related list for each.

find_real_file.png

 find_real_file.png