Search code examples
ioscsvfilemaker

Filemaker Pro 12 Exporting current 'Records being browsed' as Excel on 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: "[email protected]"; 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? Thanks in advance.

EDIT: Ironically after some testing with different scripts, the script I posted here works now correctly.


Solution

  • The Export Records function exports the current found set - the same as Records Being Browsed. This indicates that other issues are keeping your script from working. You might want to look at the Related Record and which set is found. Use a temporarily pause just before the Import Records function is called to see what set is present.

    Also, keep in mind that if there is an error with your Go to Related Record call, 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 you would expect.