RELATED LIST: How to change the related list filter?

Ridhima_1
Tera Contributor

Hi,

Greetings for the day!
I have a requirement to update the related list filter on User table.
On user form we have "Incident>Opened_by" related list with filter as Opened by is the user (User's whose form we are viewing). We want the filter as Opened by or Incident's Caller is the user (User's whose form we are viewing).

Please assist here, Thanks in advance!

Regards

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

In this case it is best to create a new custom Related List.  If you're not familiar, do this via System Definition > Relationships in the left nav.  Create a new record that looks something like this:

BradBowman_0-1717430238826.png

With the Name being whatever you want to appear on the Related List tab.  Here is the Query with script:

function refineQuery(current, parent) {
	current.addEncodedQuery('opened_by=' + parent.sys_id + '^ORcaller_id=' + parent.sys_id);
})(current, parent);

Add this Related List to your User form, then you can change the column layout like any other list.

 

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

In this case it is best to create a new custom Related List.  If you're not familiar, do this via System Definition > Relationships in the left nav.  Create a new record that looks something like this:

BradBowman_0-1717430238826.png

With the Name being whatever you want to appear on the Related List tab.  Here is the Query with script:

function refineQuery(current, parent) {
	current.addEncodedQuery('opened_by=' + parent.sys_id + '^ORcaller_id=' + parent.sys_id);
})(current, parent);

Add this Related List to your User form, then you can change the column layout like any other list.

 

Thanks Brad, it worked as expected.

Sujatha V M
Kilo Patron
Kilo Patron

@Ridhima_1  You can modify the default filter of a related list by right clicking on one of the column headers / field names in the related list > Configure > List Control in the List Control form if the Edit default filter field is not present right click on the form header > Configure > Form Layout and add the Edit default filter field as a selected field.

 

Reference link : https://www.servicenow.com/community/developer-forum/how-do-you-set-the-default-filter-for-a-related...

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.