Custom Relationship (Defined Related List)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 04:12 AM
I am trying to created a custom related list (Relationship menu) and able to setup the fields, script etc.
I am trying to not show the related list if it has no records. So I have set the 'Omit if empty' to true on list control.
Below is the format of my related list query script currently.
if(validData)
{
addquery to show the required data
}
If I am leaving the else part blank, it is end up pulling all the records from the table.
How would I handle the else part to return no data other than adding a invalid query? Is there a elegant way to do this?
- Labels:
-
Best Practices
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 06:23 AM
There might be a misunderstanding on the functionality. The addQuery part only adds a filter on the current query from the table where it's applied. It means if you do not add a filter it will just get the entire table back.
Now, as a workaround (I haven't tested it), I would suggest you try in the 'else' clause something like this:
if(validData)
{
addquery to show the required data
}
else
{
current.setLimit(0);
}
Not the most elegant way indeed!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 06:32 AM
This picks out and displays 50 records which means there could be default value of setLimit function.
I am currently doing this as the else part to fail the query.
current.addQuery("sys_id",'x');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 06:37 AM
That's a bit strange, as I don't see a default limit set in GlideRecord class.
And running this on my own instance (jakarta):
var gr = new GlideRecord('incident');
gr.setLimit(0);
gr.query();
gs.print(gr.getRowCount());
I get:
[0:00:00.001] Script completed in scope global: script
*** Script: 0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2017 06:46 AM
This does appear to be running in background script but not on related list definition.