4 Replies Latest reply on May 12, 2014 6:57 AM by JoshO'Brien

    Barcode Script to find records

    JoshO'Brien

      Title

      Barcode Script to find records

      Post

           Hi 

            

           I am new to filemaker development so will describe step by step what we are trying to do.

            

           we wich to use filemaker go on the iPhone to scan an asset tag and return the record its associated with if no record is found a new record is created with the barcode info populated in the correct field.

            

           we have an older version that worked using an external barcode reader app but we would like to use the barcode scanning within filemaker to avoid paying for the barcode app.

           the original scripts for this process were broken into three steps.

      SCAN:
            
           "cnsbarcode://scan?profile=HDD”
            
            
      iPhone Asset search from scan:
            
           Set Error Capture [On]
           Set Variable [$$FAN]
           Show All Records
           Set Variable [$$FAN; Value:Get ( ScriptParameter )]
      #Find if Workstation
           Go to Layout [“Asset Details | iPhone” (Assets)]
           Perform Find [Restore]
           If [Get ( LastError ) = 401]
           Show Custom Dialog [“None Found”; “There are no assets found with that tag. Would you like to add a new one?”]
           If [Get ( LastMessageChoice ) = 1]
           Perform Script [“Scan_return”]
           End If
           End If
           Set Variable [$$FAN]
            
            
      Scan Return
            
           New Record/Request
           Set Field [Assets::Internal ID; $$FAN]
            

           Now i don't know if these can be adapted to use the newer option 

           Insert from Device [Assets::Internal ID; Type: Bar Code; Camera: Back; Resolution: Full]

           or if its better to create new scripts from scratch.

           Any help will be very much appreciated.

            

           Thanks

            

            

        • 1. Re: Barcode Script to find records
          philmodjunk

               I suggest adding a global text field into which you scan data using the newly added Insert From Device script step. A script can then take the data in the global field and perform the needed find much like you appear to be using the $$FAN variable for in your current script.

               Freeze Window
               Set Error Capture [on]
               Go to Layout ["barcode scan" ] --> you must be on a layout where the field into which you intend to scan data is present and accessible
               Set Field [Assets::gBarcode ; "" ]
               Insert From Device [Assets::gBarcode ; Type: Barcode ; Camera: Back ; Resolution: Full ]
               If [ Get ( LastError ) = 1 // user tapped "cancel" on barcode scanner screen]
                  Go to Layout [original layout]
               Else
                  Go to Layout [“Asset Details | iPhone” (Assets) ]
                  Enter find mode [] ---> clear the pause check box
                  Set Field [Assets::Barcode ; Assets::gBarcode ] ---> this step does not work in find mode unless gBarcode has global storage specified
                  Perform Find []
                  If [ Not Get ( FoundCount ) // no asset record found ]
                       Show Custom Dialog [“None Found”; “There are no assets found with that tag. Would you like to add a new one?”]
                  # and so forth...
                

          • 2. Re: Barcode Script to find records
            JoshO'Brien

                 Hi Phil

                 thanks for this and excuse my ignorance but when inserting the line

            Set Field [Assets::Barcode ; Assets::gBarcode ] ---> this step does not work in find mode unless gBarcode has global storage specified

                 There are two options available to set filed specify target field and calculated result i assume that calculated result is required as i can see of no other way of including both fields.

                 when i uses calculated result and input the following for my fields:

                 Assets::Internal ID ; Assets::gBarcode

                 i get the error:

                 An operator (e.g. +,-,*,...) is expected here.

                 Internal ID is our barcode filed in our new database.

                 i have set the field gBarcode to global storage 

                  

                 any suggestions would be much appreciated 

                  

                 thanks

                  

                 Josh

            • 3. Re: Barcode Script to find records
              philmodjunk

                   When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

              • 4. Re: Barcode Script to find records
                JoshO'Brien

                     Thank you for this its working perfectly now cheers.