Custom Related List - Empty List field on Parent Causing Issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 12:00 PM
When creating a custom related list to display user records from a list type field on the parent table, when the parent field is empty, the related list is showing ALL user records. (Script below);
Applies to table : custom table
Queries from table: sys_user
//Script to query list type field on parent (references sys_user)
var poi = parent.getValue("poi").toString().split(",");//array of users in list field
current.addQuery("sys_id", poi);
When there are user records in the parent list field, the relationship is accurate, however, when the parent field is empty (poi), the related list shows ALL user records. How can we provide validation on the parent field object to stop any query if the field is empty?
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 02:29 PM
Try using an if statement to confirm it is not empty.
var par = parent.getValue("poi").toString();
if(par !== ''){
var poi = par.split(",");//array of users in list field
current.addQuery("sys_id", poi);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:09 AM
I tried using use that script and unfortunately with an empty list field, it is still returning all records from the user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:35 AM
Hi,
Try this
var poi = parent.getValue("poi").toString();
current.addEncodedQuery("sys_idIN" + poi);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 03:56 AM
Unfortunately that doesn't work either for empty or non-empty list fields.