- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2020 01:05 AM
Hi There,
I have written Before Query Business Rule on Incident table to sort 'caller_id' field for list view. It is working fine but I want this code should only execute for related list.
For Example: Shorting should only apply to related list records (Problem -> Incident), not to incident table's related list records.
Below are the code:
(function executeRule(current, previous /*null when async*/) {
gs.getUser().savePreference('incident.db.order','caller_id');
gs.getUser().savePreference('incident.db.order.direction','ASC');
})(current, previous);
I tried with RP.isRelatedList() , but no luck.
Any lead will be appreciated.
Regards,
Abhishek
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 12:22 AM
Add this condition to you business rule and then it will run only where incident is used as related list.
JSUtil.notNil(GlideTransaction.get().getPageName()) && !(GlideTransaction.get().getPageName().endsWith("_list")) && gs.tableExists(GlideTransaction.get().getPageName()+"")
-Tanaji
Please mark reply correct/helpful if applicable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2020 02:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2020 02:22 AM
Hi Abhishek,
The method above you have used will apply to any list view whether related or not for incident. If you want a sorted related list on Problem, you should create a relationship table where you can query and orderby.
Applies to table: Problem
Queries: Incident
Relationship record
Problem Record with ordered related list:
Note how the related list is ordered by newest to oldest without having filtered the related list.
Please mark as solved/helpful if this has worked for you.
Thanks,
Enrique
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2020 03:03 AM
Hi,
please check below links:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 12:22 AM
Add this condition to you business rule and then it will run only where incident is used as related list.
JSUtil.notNil(GlideTransaction.get().getPageName()) && !(GlideTransaction.get().getPageName().endsWith("_list")) && gs.tableExists(GlideTransaction.get().getPageName()+"")
-Tanaji
Please mark reply correct/helpful if applicable