12 Replies Latest reply on Feb 20, 2017 3:27 AM by g.tam

    Trouble sending a CSV attachment on iPhone

    g.tam

      I keep alternating the template "invoice" solution of FMP15.  Now I am trying to email invoices by attaching a CSV file, which is something I wanna do when I'm away from my office.  The result is fine when I test the iPhone layout on Mac, however, there were no attachment when I test it on iPhone with FM Go.  Why would that happen?  Please kindly make suggestions for me to check on.  FYI, I'm no programmer, just trying to make a simple sales-inventory program.

        • 1. Re: Trouble sending a CSV attachment on iPhone
          beverly

          Can you post your script? I do this all the time (email CSV from my iPhone). The paths on iOS can be slightly different than on desktop.

           

          You can use:

          Get ( TemporaryPath )

          Get ( DocumentsPath )

          on iOS, but not:

          Get ( DesktopPath)

          for example, to "save" the export to a variable that becomes your attachment in the email.

           

          Sent from miPhone

          • 2. Re: Trouble sending a CSV attachment on iPhone
            g.tam

            It was duplicated and altered from the original script "Send Invoice by Email":

            1 Set Error Capture [ On ]

            2 Freeze Window

            3 Go to Related Record [ Show only related records

            From table: "Invoice Data" ;

            Using Layout: <Current Layout> ; New window ]

            4 If [ Get ( LastError ) = 0 ]

            5 Set Variable [ $PATH ;

            Value: Get ( TemporaryPath ) & "Order " & "Customers::Client ID" & ".csv"

            6 Save Records as Excel [ Restore ;

            with dialog: Off ; "$PATH" ;

            Records being browsed ]

            7 Send Mail [ Send via E-mail Client ;

            with dialog: On ;

            To: "my company email" ;

            Subject: "Order #" & Customers::Client ID & Invoices::Date ; "$PATH" ]

            8 Set Field [ Invoices::Sent On ; Get ( CurrentTimestamp) ]

            9 Close Window [ Current Window ]

            10 End If

            • 3. Re: Trouble sending a CSV attachment on iPhone
              philmodjunk

              Set error capture [on] will keep any error message from displaying. Try disabling that step and see if an error message pops up.

              1 of 1 people found this helpful
              • 4. Re: Trouble sending a CSV attachment on iPhone
                beverly

                Are you sure there are records exported (that the document is not empty)? You might try the documents path to see that something is created.

                 

                Also, are you doing this on stand-alone FMGo or hosted file opened in FMGo?

                 

                You said works on desktop.

                 

                Sent from miPhone

                • 5. Re: Trouble sending a CSV attachment on iPhone
                  arjen.evertse

                  You are using the Save Records as Excel script step which is not supported in FM Go.

                   

                  You might want to modify your script using Export Records. It is supported on FM Go using the csv format.

                  1 of 1 people found this helpful
                  • 6. Re: Trouble sending a CSV attachment on iPhone
                    beverly

                    Good catch! I presumed the script was changed to match the topic of 'CSV attachment'.

                     

                    Sent from miPhone

                    • 7. Re: Trouble sending a CSV attachment on iPhone
                      arjen.evertse

                      And you might want to implement some more error trapping.

                       

                      There is no way for FM to know if the email pushed to the client was actually sent, but in your current script the Sent On field will be set even any of the previous script step created an error. You currently only avoid the second part of the script from running in case the GTRR does not work, but as you see there are more possibilities for errors.

                      1 of 1 people found this helpful
                      • 8. Re: Trouble sending a CSV attachment on iPhone
                        g.tam

                        It works now.  Thank you very much for your advise.  And thanks to Beverly too.  I also find where I can check details of each step such as if it is compatible with FM Go or not.

                         

                        Since we are on this topic, I hope I can get more advise from you.  Originally, I wanted to duplicate and simplify the "template" Invoice solution into a separate iOS sales order solution. Sales Order solution (with limited access to customer and product details) sends orders (it is just an invoice without <Invoice ID> ) back to office and let the office (with full data access) to import the sales orders, possibly deleting items if out of stock, and make invoices.  The main idea is to save time and eliminating chance of human mistakes when inputing. However, I realised a lot of time is needed to match the field names at times of importing record.  I wonder if I'm wrong about this.  Please kindly advise.

                        FMC-ImportingRecord.jpg

                        • 9. Re: Trouble sending a CSV attachment on iPhone
                          g.tam

                          Thanks for your advise.  I took those steps out and it responded that no file was attached even tho I switched to "Export Records".  I figured out what went wrong at last.

                          • 10. Re: Trouble sending a CSV attachment on iPhone
                            arjen.evertse

                            If I understand correctly your solution used on Go is local and separate from your back office solution. If so, your best approach would be:

                             

                            1: Make sure you have your field names matching between the two solutions

                            2: Use Export Records with type Excel Workbooks instead of CSV, this will give you the field names in the first row

                             

                            Yes, it sounds strange but although Save Records as Excel is an unsupported script step on Go, Export Records with the Excel type is supported.

                             

                            Since you have the field names in the file now, you can use Import Records, check Don't import first record (contains field names) and select Arrange by: field names. This will automatically set the import order to match the columns of the Excel file to match with the correct fields as long as the names are the same.

                             

                             

                            You could also consider to use a plugin on your back office system that can prompt the user with a File selection dialog and grap the path of the selected file to a variable. In this way you could script the import of the records and save these settings in your import script.

                             

                            There are several plugins available, you might want to check out the free BaseElements plugin: https://baseelementsplugin.zendesk.com/hc/en-us/articles/207324927-BE-SelectFile

                            1 of 1 people found this helpful
                            • 11. Re: Trouble sending a CSV attachment on iPhone
                              arjen.evertse

                              About the compatibility of script steps, Filemaker Help has descriptions on each script step explaining compatibility. Pay extra attention to the ones that say Partly Supported, you need to grap the details on that from the remarks in the bottom of the article.

                               

                              Besides from that, while scripting make sure you select the right compatibility according to the target platform. This will display unsupported steps in gray color or even might display unsupported settings from supported steps in gray.

                               

                              • 12. Re: Trouble sending a CSV attachment on iPhone
                                g.tam

                                Yes, that's my scenario.  I will follow your instructions and test it out.  I will come back and update my progress.  BTW, big thanks for your detail explanation, as a newbie to programming, it helps a lot for me to understand what needs to be done and why.