Genx Posted August 18, 2005 Posted August 18, 2005 Is there a way i can put in a script step to check if a related record exists? Reply would be great cheers, genx
Reed Posted August 18, 2005 Posted August 18, 2005 You can use IsValid(RelatedTable::relatedSerialField) inside an If[] script step.
-Queue- Posted August 18, 2005 Posted August 18, 2005 Note that IsValid could return false even if there is a related record (see FM Help). IsEmpty is more reliable and, from what I have read, optimized for this use.
sbg2 Posted August 19, 2005 Posted August 19, 2005 I have been using Count(TO::Field) with consistent results, is there any reason I should be using IsEmpty instead?
Ender Posted August 19, 2005 Posted August 19, 2005 If there are lots of related records, Count() will be slower, as it actually has to count them all.
colinbythesea Posted August 22, 2005 Posted August 22, 2005 you could also use if(sum(any related numeric field)=0). Use this successfully in scripts as long as there is always going to be a number in the numeric fields, e.g. account number. You could also set up a calculation field in your table that returns a 1 if there is a count or sum greater than zero in related tables and use this as a flag in scripts. You could also go to related records and check file, layout or table names to check if its gone to any.
Søren Dyhr Posted August 22, 2005 Posted August 22, 2005 if(sum(any related numeric field)=0) You havn't understood what Ender wrote, littering the calc with yet another function ...is making things worse, all aggregate functions suffer from this artifact. But we're way beyond 4000 records in the related, before any noticable difference shows. --sd
comment Posted August 22, 2005 Posted August 22, 2005 If the related field is a number field that is guaranteed not to contain zero (e.g. a serial number), you can make it simply: If [ related::serialID ]
Recommended Posts
This topic is 7032 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now