Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get(LastError)=401 vs Get(FoundCount)=0

Featured Replies

Get(LastError)=401 vs Get(FoundCount)=0

Is there any advantage/disadvantage to using either of these, when scripting and checking if a find returns no matching records? (Obviously I always test for the last error immediately after the find.)

Could either ever be tripped up and give a wrong result?

I've been using FM since the early days and have always tested against error 401, but in recent months I've started to convert a system and in new scipts I've been erring towards get(foundcount), perhaps for readability...

(This particular system I'm working on is v11, and will be upgraded to v12 next year.)

AFAIK they are equivalent for testing the result of a Find. However as you pointed out, Get( FoundCount ) is more readable, what I would call "self-commenting code," whereas with an error code I'd be compelled to include a comment.

  • 1 month later...

Every script step has its error code, even where there is no error, code for that will be "0".

So if after script step FoundRecord you get error code "401", after next script step this number will alter.

Let's look Get (FoundCount) - the result of this operation is much more stable, even when the script in over.

So maybe here you can feel the difference or save your time in future. Get (FoundCount) is more useful when you have several scripts running.

Hope you catch the drill.

Not all find errors are 401. There's a few, but one that comes to mind is 400 (find criteria are empty). That will not result in an empty set, but rather a found set of the records before the find was initiated.

I recommend a "belt and suspenders" calculation:

Get ( LastError ) or ( Get ( FoundCount ) = 0 )

Also, keep in mind the OnModeEntry scripts will trigger on a find and the error will return at the beginning of the trigger script.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.