Advanced reference qualifer taking time

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 05:35 AM
Hi Team,
We have an OOTB reference field 'Account To' on Account Relationship table. There is already a advanced reference qualifier written as below which works fine but we need to restrict below to only show parent accounts
javascript:var ret='customer=true'; if (current.relationship_type.to == 'partner') ret = 'partner=true'; ret + '^sys_id!=' + current.from_company
For that we have written script include as below but it takes lot of time to fetch the records whereas above OOTB qualifier does not take much time.
Infact my script include returns only 50000 records whereas above returns 1.4Lakhs still above one is fast and mine below is slow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 07:03 AM - edited ‎06-26-2024 07:03 AM
Looping through the list to collect the sys_ids and then querying the table by a list of sys_ids is very inefficient. In fact, you query the database twice for no reason. All you need to do is put your encoded query directly into the reference qualifier like this:
javascript: 'account_parentISEMPTY^customer=true^sys_id!='+current.from_company
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/