How do I detect that a record has no related records? I've found that
"Go To Related Record" doesn't protest if there are no related records
so catching an error doesn't work. I've also searched the Get functions
for something that returns a count of related records to no avail.
Charlie
On 2019-07-30 01:13:20 +0000, Charles H. Sampson said:
How do I detect that a record has no related records? I've found that
"Go To Related Record" doesn't protest if there are no related records
so catching an error doesn't work. I've also searched the Get functions
for something that returns a count of related records to no avail.
There's probably a few ways, but perhaps the easiest is to simply count
the number of related records using a related field that must always
contain data - the obvious one being the related records' Child-Key
field itself. In the Parent Table, you can create a Calculation field
like:
NumRelatedRecords Calculation, Number Result
= Count(Relationship::Related_Child_KeyField)
or you can simply use the same calculation in a Script, within an If statement's test for example..
If that calculates as zero, then there are no related records.
You may even already have that field in the Parent Table since it can
often be handy to display the count underneath a Portal.
Helpful Harry :o)
Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
On 2019-07-30 01:13:20 +0000, Charles H. Sampson said:
How do I detect that a record has no related records? I've found that
"Go To Related Record" doesn't protest if there are no related records
so catching an error doesn't work. I've also searched the Get functions
for something that returns a count of related records to no avail.
There's probably a few ways, but perhaps the easiest is to simply count
the number of related records using a related field that must always
contain data - the obvious one being the related records' Child-Key
field itself. In the Parent Table, you can create a Calculation field
like:
NumRelatedRecords Calculation, Number Result
= Count(Relationship::Related_Child_KeyField)
or you can simply use the same calculation in a Script, within an If
statement's test for example..
If that calculates as zero, then there are no related records.
You may even already have that field in the Parent Table since it can
often be handy to display the count underneath a Portal.
Helpful Harry :o)
Worked like a champ, Harry. Thanks yet again. You'd think (or at least I would think) that with the many Get functions, not a few of them having
to do with the number of records in a set, there would be one something
like Get (RelatedRecordsCount).
Charlie
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 234:52:28 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,700 |