There is no need to preface the path with "filemac:" when using Get( TemporaryPath ) function.Also, make sure the file name does not have any illegal characters, for macOS colons are illegal.--EDIT: oops I completely misread the question.--The temporary folder gets deleted at the end of each FMP session, so no surprise you get the error "The file cannot be found: <file_name_here.pdf>" because the file has been deleted. When putting the pdf into the container, make sure you INSERT the file and not use a REFERENCE. Your posted script shows you know to insert the file, but the script's behaviour suggests that it's inserting a reference.
If you are inserting the file and not just the reference make sure you have committed the record. A normal shut down should do this but that is the only other thing I see other than storing it as a reference instead of actually inserting the file.
Make sure that the script hasn't raced ahead and is trying to insert the file before the PDF has actually been created. Try putting a pause/resume step between the save and insert steps. Start with an infinite pause, then, if that works, try using shorter and shorter pauses.
designer, just adding questions:
Noticed that you are appending “.pdf” to whatever is in then field SOAP::soapID
Question why use “Save Records as PDF” ? would that not automatically append the “.pdf” ?
Instead of “Save Records as PDF”, why not use “Export Records”, just a question !!
Is this script set to run when you restart the file ?
The script step in question is simply:
Insert File [ Insert ; Display content ; Compress when possible ; FaxLog::document ; “$fileName” ]
It does Work. The script is not unable to find the document (trying to insert before the PDF has been created). It is correctly set to INSERT the document. It just seems to be acting like a REFERENCE was created to the file (that eventually disappears from the temporary location). The real question is: WHY?
As for the suggestion about Commit. This did not fix it, so...
I recorded the container attribute in the log file after it was imported using:
Set Variable [ $storageTypeAttribute ; Value: GetContainerAttribute (FaxLog::document ; "storageType" ) ]
The log recorded: ==> container type: External (Secure)
so it would appear that the document is indeed inserted (the possible returned values are Embedded, External (Secure), External (Open), File Reference, Text.).
I exited FileMaker and re-opened it and the file. The document again shows "the file cannot be found: <file_Name.pdf>"
I am baffled. Is the real problem that the document in the External Secure Store is not being found?
As to the other comments and questions:
With respect to filename: if I don't add the extension (but specify the filename) the Mac does not append the extension. Adding it manually makes my life easier.
Save Records as PDF is used to create a formatted, ready to fax document. Export Records does not create a formatted PDF (if I am wrong about this, then I apologize, but I am fairly certain that it does not)
Is the secure storage saving to the temporary folder?
Is the file hosted?
Sorry to ask something silly, but I am down to silly answers because I don't understand how this is happening to you either. :-)
The field is not set to global storage, correct? (if the file is hosted it would matter)