Need a way to apply direct filter to the related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 08:16 AM
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.
This use case I've already implemented using script with the Relationship option, here below is the screen shot of the script
Please get back to me if you need more information. Appreciate your help!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 08:22 AM
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
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 09:25 AM
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,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2022 06:47 AM
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");
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 08:52 AM
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
Snow doc :
https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/list-administration/concept/c_ControlTheListSortSequence.html