Jump to content

Container field scripting-Insert PDF


This topic is 3286 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello forum,

I had a few questions regarding inserting, then retrieving a PDF from a container field.  Scripts attached.

What I have is a table for Customers related to a table Customer_contact.  In the Customers Table I have a layout/procedure to write letters to customers, either individually, or in bulk.  Then print. What I would then like to do is have the option (in the Customer_contact table) to either just put a record of the contact (date, which letter sent) or save a copy of the entire letter in a container field as a PDF.  The reason for the 2 options are I only really want to save the letters that are related to unpaid invoices, not the bulk letters, newsletters, etc.

So I came up with these 2 scripts to save and retrieve.  It does work, but I read up on saving to a temporary path to embed the pdf into the container field, but I am confused by the method.  So when my script runs, it does what I need it to do, but leaves an untitled.pdf file on my desktop (which I don't like, but I did script it that way).  It does work but I always wonder if it is correct, and if there is a better way.  I do want to embed the pdf's into the container, not store remotely

My questions are:

1.  Is the first script correct (the steps with the arrows specifically, but overall too)

2.  Is the second script correct for retrieval?  Obviously if I have to change the first script, the second will need updating.

Any help, opinions, ridicule, pointers, are always appreciated.

Thanks

Steve

PS.  I'll always be the only user, so record locking with the loop script wont hurt me, but if an alternate method is better, I'm always interested in learning

ContainerScripts.png

Link to comment
Share on other sites

Steve,

You should set a $path, then Save As PDF using that $path and export using a $path as well.

So, right before your Save Records as PDF (for example):

Set Variable $path; Get ( TemporaryPath) & "Letter_" & Customer::Name & ".pdf"

same thing right before Export Field Contents.

Edited by bcooney
  • Like 1
Link to comment
Share on other sites

Quick follow up.  It seems that after running this script it leaves a pdf of the last pdf created in the same folder from which FileMaker was opened.  Is this SOP? If so, I guess I could just delete it at the end of the day.  Is there is an actual way to delete the $path.pdf from the folder?

Link to comment
Share on other sites

Hi Barbara, thanks for the sample file.  I couldn't get yours to work.  Watching the create letters script with the debugger, if fails to set a variable @ this script step:

Set Variable[ $ids_people; Value:people~all::list_of_ids]

Then consequently, it immediately exits the loop at this step:

Exit Loop If [$I > ValueCount ($ids_people)]

I did however correct my problem (I think) by using Export Field Contents, $path, with no field reference.

Thanks again for your help

Steve

Edited by Steve Martino
typo
Link to comment
Share on other sites

Sorry, I inadvertently used a FM13 feature list of summary field to grab IDs. 

But, the goal was to better understand setting $paths. 

Edited by bcooney
Link to comment
Share on other sites

This topic is 3286 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.