Announcements
Anyone else having their sanity chipped away by repeatedly writing a bug into code by using "NOT Rec.ISEMPTY" incorrectly? ISEMPTY does exactly what it says, and in a timely manner, but somehow just feels like it goes against the whole positive naming convention.
I doubt there will be much force behind any attempt to have an HASRECORDS or like named function added, but it really would keep things consistent seeing as every devloper I meet makes the same mistake on occasion, and it sits there in code as the brain of every developer happily filters the ISEMPTY line out when they look at the logic.
Well I'm definitely lost in double negatives now.
No one here autogenerate responses.
I'm going to take a wild stab that you guys are autogenerating replies and not reading the posts.
Stefano is right, if you iterate for sure you want to use something along the lines of findfirst or findset, depending on what you need to achieve.
My previous suggestion was strictly to the point of what's the most efficient alternative to see if you have records in a record variable, without necessarily doing something with it afterwards, but triggering another event in case no record is found. And the fastest one is a method that doesn't retrieve a record from the database.
Of course considering BC has the Azure platform behind the scenes and assuming that there is no crazy iteration of the code in question, you would assume a find is actually best fit at the end of the day, it won't impact your performance.
I personally prefer using findfirst, or findset, depending on what I want to do after I find the records, but there are situations when using isempty makes perfect sense.
For instance if a certain filtered record.isempty then I may want to create it with an insert.
Cheers,
Robert
If the scope is to check if a table contains records, ISEMPTY is faster that COUNT (and it's the fastest way).
The onlything to remember is that ISEMPTY or COUNT do not fetch any record from the table.
So, a bad code is the following:
Customer.SETFILTER(“Currency Code”, ‘<>%1’, ”);
IF NOT Customer.ISEMPTY() THEN
REPEAT
…
UNTIL (Customer.NEXT = 0);
Use one of the FIND() functions if you want to iterate through, or use the filtered records.
Hi Mark,
Have you tried rec.Count or Countapprox methods?
Cheers,
Robert
If this helps in resolving your issue, please verify my answer!
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156