I am working on an app to be used with Filemaker Go for stocktaking using barcode scanning. When a barcode is scan that is not in the existing database I want the user to be able to add it but I have run into some problems. It seems like there are system generated error messages in the perform find script method which interferes with the flow that I am trying to create. Is there a way to branch within the Perform find script step or turn off the auto creation of this error messages.
Many thanks.
HI.
This is a pretty common use case: see if a record exists. If not, create it.
So you'd need to do some logic. You need to capture for the error that the record doesn't exist and then take the user to a layout in which to enter the new record's data (or you could even get the data from the barcode).
To capture the error, first surpress the errors:
Set Error Capture [on] // This prevents that horrible dialog informing the user that no records exists.
Do your normal routine of allowing the scanned data to be used in the find. Immediately after the Perform Find. capture that step's error # in a variable:
Set variable $error: [Get (LastError)]
Then use conditional logic:
IF $error > 0
Take user to a layout to enter data
New record
Exit script
End if
-- This will allow the user to enter data into a new record if that one doesn't exist.
If you want to capture the data from the barcode, you could set the barcode's contents to a variable (or many) and use those variables to fill in the new record.