2 Replies Latest reply on Jan 10, 2013 9:05 AM by StevenReynolds

    Exporting records as .csv in iOS



      Exporting records as .csv in iOS


      I'm managing a Filemaker Pro 12 solution to create purchase orders and send them via email for the iPad but the iOS Platform doesn't allow to export Excel files.

           Currently we are sending the orders as a .pdf file but the warehouse has to manually approve each order. The solution we were thinking of is to send a .csv file attached to an email so that the warehouse has less work.

           I'm using 3 different tables to create a order. A table that stores the products, a container table (to set the quantity, discount etc.) and a table for the order itself. So you can for example create three product-A and two Product-B in an order which works fine. My PDF solution uses an extra Layout and works fine. On a PC or Mac you can export Excel files with a script and the "Save Records as Excel" function, but this is not available on iOS, so I'm looking for alternatives.

           The script I came up with to send the .csv file via email looks like this:

      Set Error Capture [On]
      Freeze Window
      Go to Related Record [Show only related records; From table "Orders_Container"; Using Layout: "MailLayout" (Orders_Container); New Window]
      If( Get (LastError) = 0)
          Sort Records[ Restore; No dialog]
          Set Variable[ $FILE; Value:Get (TemporaryPath ) & "file.csv" ]
          Export Records [No dialog; "$FILE"; Windows(ANSI)]
          Send Mail[Send via E-mail Client; To: "customer@web.com"; Subject: "Order"; "$FILE"]
      End If
      Close Windows [Current Window]

           I tried to use the function "Export Records" but it exports all records of the current customer instead of the 'Records being browsed' which is only available for the PDF export. I've tried to do this but on iOS you can't create a new file to export and I can't come up with something else. I don't want the users to use Menu -> Export -> E-Mail because they will have to enter 3-4 Email addresses each time which is way to time consuming (this also exports all records instead of the ones which are currently being browsed). Is there any way to export the records that are currently open, save those in a .csv file and send a mail with the file attached?

           I've already posted this question here. Also thanks in advance!

        • 1. Re: Exporting records as .csv in iOS

               Export Records exports the current found set--the equivlent of "Records Being Browsed". Thus some other issue here is keeping your script from producing the correct found set or the Export Records step is exporting from a different found set than you expected. You might want to temporarily insert a "pause" just before the Import Records step so you can inspect and see what found set is present.

               Also, keep in mind that if there is an error with your GTRR, nothing happens. A record created by a previous export would then remain in place and this then might show a different set of records than what was expected.

          • 2. Re: Exporting records as .csv in iOS

                 Hi, Thanks for the answer, ironically after some testing with different scripts, the script I posted works now correctly.