4 Replies Latest reply on Oct 3, 2016 6:45 PM by rouelf

    How to import in FMGO

    jlcalhoun

      I have a excel file in a container field in a table in a app running in FMGO.  I want to export it and import back into a table.  I can only get it to work outside of FMGO, any ideas??

        • 1. Re: How to import in FMGO
          schamblee

          FileMaker Go only supports importing from one FileMaker Pro file to another FileMaker Pro file.

           

          FileMaker Go 15 Development Guide

          • 2. Re: How to import in FMGO
            Johan Hedman

            Build it so that you import Excel-files inside FileMaker and then look at your records in FileMaker Go.

            • 3. Re: How to import in FMGO
              rouelf

              jlcalhoun, the question is not clear enough as to what you want to do, in any case maybe the following is helpful. I presume you would like to use an Excel file (.csv) to import the data into a text field. Then, if desired you can parse the data into appropriate records and fields.

               

              1. You can always insert a file into a container in iOS, OS X, Windows, using “Insert File”. In your case use an Excel File with comma separated values (.csv).

               

              2. Script might look like this, In this case we are using global fields in table named Glbs.  - - Any text with and after ######  is note for explanation “DO NOT INCLUDE”.

               

              3. Use a Button to execute the script below, then if desired you can parse the data into appropriate records and fields:

               

              Freeze Window

              Go to Layout [ “Glbs” (Glbs) ]

              Set Field [ Glbs::g_Text; "" ]        ######  This is a Text Field

              Insert File [ Insert ; Never compress ; Glbs::g_Import_File ]       ######  This is a Container Field. The file ExcelFile.csv, must be in the “Device” page of FM Go to be chosen.


              Set Variable [ $newFile; Value:"File.txt" ]
              Set Variable [ $Path; Value:Get ( TemporaryPath ) & $newFile ]
              Export Field Contents [ Glbs::g_Import_File ; “$Path” ]       ######  Specify Output Path  “filewin:$Path” Carriage Return “filemac:$Path”

                    If [ Get ( Device ) = 2 ]

                    # Use this for Windows

                    Insert from URL [ Glbs::g_Text; "file://" & $Path ] [ No dialog ]        ######  Give  Glbs::g_Text  field the Object Name “Text”.

              Else

                    # Use this for OSX and iOS

                    Insert from URL [ Glbs::g_Text; "file:/" & $Path ] [ No dialog ]

              End If

              # Replace windows CRLF

              If [ PatternCount ( Glbs::g_Text ; Char ( 13 ) & Char ( 10 ) ) ]
                    Set Field [ Glbs::g_Text; Substitute ( Glbs::g_Text ; Char ( 13 ) & Char ( 10 ) ; "¶" ) ]

              End If

              #Replace iOS Unix (LF)

              If [ PatternCount ( GetAsText ( Glbs::g_Text ) ; Char ( 10 ) ) ]
                    Set Field [ Glbs::g_Text; Substitute ( Glbs::g_Text ; Char ( 10 ) ; "¶" ) ]

              End If
              Set Field
              [ Glbs::g_CSV; "" ]       
              ######  This is a Text Field

              Set Web Viewer [ Object Name: "CSV"; Action: Reset ]       
              ######  Insert a WebViewer, Give the Web Viewer the Object Name “CSV”; and point the Web Viewer to the text field  Glbs::g_CSV

              Go to Object [ Object Name: "CSV" ]
              If [ Get ( Device ) = 3 ]

                    # Use this for iPad

                    Set Field [ Glbs::g_CSV; $Path ]

              Else If [ Get ( Device ) = 4 ]

                    # Use this for iPhone

                    Set Field [ Glbs::g_CSV; $Path ]

              Else If [ Get ( Device ) = 1 ]

                    # Use this for OSX

                    Set Field [ Glbs::g_CSV; "file:/" & $Path ]

              Else If [ Get ( Device ) = 2 ]

                    # Use this for Windows

                    Set Field [ Glbs::g_CSV; "file://" & $Path ]

              End If

              • 4. Re: How to import in FMGO
                rouelf

                It seems that simply pointing a WebViewer to a .txt file in the TemporaryPath or DocumentsPath no longer works (if ever). However, replacing the script steps from above:

                 

                If [ Get ( Device ) = 3 ]

                      # Use this for iPad

                      Set Field [ Glbs::g_CSV; $Path ]

                Else If [ Get ( Device ) = 4 ]

                      # Use this for iPhone

                      Set Field [ Glbs::g_CSV; $Path ]

                ---- Change to:

                If [ Get ( Device ) > 2 ]

                      # Use this for iPhone and iPad

                      Set Field [ Glbs::g_CSV; "data:text/html" & GetAsSVG ( Import CSV::Text ) ]

                Or You Can use:

                 

                Set Field [ Glbs::g_CSV; “file:/“ & $Path ]

                 

                ----- will allow the WebViewer to display the data.

                The reason for the WebViewer is that iOS will not allow displaying text fields greater than with about 64K characters. The WebViewer does not have that limitation.