Skip 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.

Scripted find confusion

Featured Replies

I've tried everything I could think of to get the script below to behave as I would wish, but without success.

When the user fails to enter any data at the 'Enter Find Mode ' stage, (i.e. user just presses Return/Enter key)I cannot get the script to pick up the fact that no info was entered.

It jumps past 'If [Get ( FoundCount ) = 0]'etc.,

Thanks

==================

Allow User Abort [Off]

Set Error Capture [On]

Go to Layout ["To be cancelled List" (Link)]

Enter Find Mode []

Loop

Pause/Resume Script [indefinitely]

Exit Loop If [isEmpty ( Link::Code )]

New Record/Request

End Loop

Perform Find []

If [Get ( FoundCount ) = 0]

Show Custom Dialog ["No Records Selected"; "No Records Selected"]

Exit Script

Else

Perform Script ["Cancel"]

End If

Try capturing the error instead of using get(foundcount)???

get(lasterror) = 401 //No records found

or

get(lasterror) = 400 //Find criteria is empty

  • Author

Thank you ender. This worked in part. It is now trapping get(lasterror) = 400 //Find criteria is empty, but not get(lasterror) = 401 //No records found?

I replaced the code between Perform Find [] and Exit Script, with the following.

=======================

If [Get ( LastError ) = 400]

Show Custom Dialog ["No Records"; "Find criteria is empty"]

End If

If [Get ( LastError ) = 401]

Show Custom Dialog ["No Records"' "No records found"]

End If

Try storing the error in a global or using Else If:

If [Get ( LastError ) = 400]

Show Custom Dialog ["No Records"; "Find criteria is empty"]

Else If [Get ( LastError ) = 401]

Show Custom Dialog ["No Records"' "No records found"]

End If

The LastError changes after each some script steps.

Here are three options:

// 1 - your way with "else"

If [Get ( LastError ) = 400]

. Show Custom Dialog ["No Records"; "Find criteria is empty"]

Else If [Get ( LastError ) = 401]

. Show Custom Dialog ["No Records"' "No records found"]

End If

// 2 - your way with storing the error in a global

Set Field [ globalError ; Get ( LastError ) ]

If [ globalError = 400]

. Show Custom Dialog ["No Records"; "Find criteria is empty"]

End If

If [ globalError = 401]

. Show Custom Dialog ["No Records"' "No records found"]

End If

// note: this can be even more fun with a table of errors that you relate from the globalError field. Search the forums for my fancy launcher example file. So it would look more like this:

Set Field [ globalError ; Get ( LastError ) ]

Show Custom Dialog ["Error " & Error::number ; Error::description ]

// 3 - no fuss

If [ Get ( LastError ) <> 0 ]

. Show Custom Dialog ["Error"; "This computer will self-destruct in 30 seconds." ]

End If

  • Author

Thanks for the help folks.

this...

If [Get ( LastError ) = 400]

Show Custom Dialog ["No Records"; "Find criteria is empty"]

Else If [Get ( LastError ) = 401]

Show Custom Dialog ["No Records"' "No records found"]

End If

...does not appear to work for me. The script ignores it completely and displays all the records in the DB?

You might try adding that global after all, storing the error in it immediately after the Perform Find[], and seeing if there is an error.

...

Perform Find[]

Set Field [ globalError ; Get ( LastError ) ]

...

It is important that you grab the error immediately after the Perform Find[]; don't even have #comments in between them.

Silvertop:

In your original script, the Set Error Capture[on] was capturing the wrong error, the Exit Loop If[] statement. To capture the error in the find, you should move the Set Error Capture[on] to directly BEFORE the Perform Find[] statement.

-Stanley

As long as error capture is enabled before the Perform Find step, it is irrelevant at which point it is enabled. I usually turn on error capture at the very beginning of a script (after disabling user abort) and then trap for any errors throughout the script.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.