I have a solution where our stores enter deliveries into the database throughout the day. Then at a given time our dispatcher clicks a button to send those orders to WorkWave's API for route optimization. A CSV file is then returned by Workwave and imported back into our database. This populates the driver field and the expected delivery time.
What I am trying to do now is create a PDF for each store which will be emailed to them showing their deliveries for the day, which driver has them and roughly what time they will be delivered. I also want to save a copy of each of these PDFs so that if I store does not receive it for whatever reason they can log into the DB and download a copy. I know I can accomplish this by scripting each find/sort, print to PDF, send email and insert PDF to container fields. What I'd really like to do is write that code once and then simply pass a variable or two for the find and filed to insert the PDF to.
The table for the emailed PDFs is EmailedOrders, the container fields are EmailedOrders::Store_1, EmailedOrders::Store_2, EmailedOrders::Store_3 etc.
Insert File wants me to actually pick the field name for the target field from the list of fields as does Go To Field
I have tried giving each container field an Object name and then using Go to Object but I get an error code 3 command is unavailable (I'm using FMP)
I though Set Field By Name might work but can not figure a way to have the value be a file on the local machine.
Can anyone think of a way to do this where I can write the code once and then put it in a loop to run for each store?
Thanks in advance for any and all help