Need a way to apply direct filter to the related list

Kishore32
Tera Contributor

Hi,

I need to apply a filter on related list and I've created the relation between the tables using 'Relationships' option in ServiceNow.

Here is my use case what I'm looking to filter the records.

step1: We have a column called TransdtThru, I need to get the latest date records first.

step2: using latest date I need to get the records and show them in the list.

Here below is the screenshot where I need filter to add and I need to apply above steps here.

find_real_file.png

This use case I've already implemented using script with the Relationship option, here below is the screen shot of the script

find_real_file.png

Please get back to me if you need more information. Appreciate your help!! 

5 REPLIES 5

Aman Kumar S
Kilo Patron

I see you have mulitple queries, why don't you club them together using addEncodedQuery.

Although, your current approach looks fine as well, but what you are ending up with this approach?

Can I also suggest, using getValue when you are fetching the value as in line 11

Best Regards
Aman Kumar

Current approach fine, but end user should have a option to remove those filters and can apply other filters.

By using current approach, end user doesn't have the flexibility to change the filter.

Can you please elaborate more on 3rd line from your comment, actually I didn't understand. 

Thank you,

I don't think custom relationships actually allow your to add modifiable filters.

what I meant is using getValue() function for fetching values as in gr.getValue("your_field_name");

 

 

Best Regards
Aman Kumar

Sreeneketh1
Tera Contributor

Hi

Go on the Module under System Definition and Then on argument field please remove the condition created by and add condition for sent on..

 

Please read

To sort a list by multiple fields, remove everything from the filter field and place it in the arguments field. For example, if the filter specifies [Active] [is] [true] and you want to sort by category and subcategory, remove the condition and put the following in the module arguments:

active=true^ORDERBYcategory^ORDERBYsubcategory

This argument first orders by the category and then orders by the subcategory. If you want any field to be a descending sort then change ORDERBY to be ORDERBYDESC.

 

For change sort by number desc 

find_real_file.png

 

Snow doc :

https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/list-administration/concept/c_ControlTheListSortSequence.html