Search code examples
filemaker

script for barcode scanner to fill in appropriate fields


I am making a filemaker pro layout and need help with scanning from a barcode reader (in keyboard emulation mode). My barcodes have two bits of data on them: a user ID and the title of a document the barcode is attached to.

My end goal of my script is to be able to scan a barcode and output the barcode's data into the appropriate field (eg. the title of the document).

Here is what I currently have. It doesnt work, but this is what I was able to find from googling. I also attached the script to the appropriate field from the "Script Triggers" options to respond to "OnObjectKeystroke" but that still doesnt make it work.

Here is my code:

If [ Code (Get(TriggerKeystroke)) = "user1_paper1"]
    Set Field [user data::user1 ; "paper1"]
    Insert from Device [user data::user1 ; Type: Bar Code; 
    Camera: Back; Resolution: Full]
End If

thanks.


Solution

  • The Code (Get(TriggerKeystroke)) returns the ASCII code for a SINGLE keyed-in character and will never match your string. Try the script without the IF clause to see if you script trigger fires properly. I would expect it will not work as you wish, as OnObjectKeystroke will fire for each character in the string. Try the OnObjectModify or OnObjectValidate trigger.