Lots of questions here - and first off if you are looking to use Perform Script on Server to print your reports and email them. You won't be able to as that step is not server compatible. When you are in the Script Workspace the third icon from the right at the top allows you to see all the steps either in your currently selected script or in the list of all scripts which are compatible under the option you selected. Here is a screen shot of that.
So if you need to print and send pdfs at this time you'll have employ some other method or use a robot machine for that.
As for transferring your global memory variables. Think of the script that runs on server just as another user that has logged into the server, except that the other user in this case is really just a clone of you. So if you need to have anything transfer over to the script running on server you'll have pass that over in your script parameters. At Beezwax we have been using for a long time a reliable method of passing script parameters based on a set of custom functions that were designed by Six Fried Rice many years back with some slight modifications to them.
To learn more about PSoS ( Perform Script on Server ) I wrote 2 blog posts when it first came out that are worth checking out.
As far as printing goes there is something that we have used in the past but don't have all the details about it but you can look it up and read about it at wkhtmltopdf. Basically taking HTML formatted data and generating a PDF.
Best - Vince
thanks for bringing this back to attention! Is there no way to have 'pinned' postings/threads here?
I am not sure about that.
As previously noted by Vince, you can't create PDFs on the server. But you can create it in FMP and store it in a container field and PSoS and export it on the server to the Temporary folder and attach it to an email sent by the server. That would solve your problem.
Isn't the export field contents step not server compatible.
I think to accomplish this one would have to employ the technique discussed in this blog post.
Or am I missing something.
Thank you for the reply,
I have made a table with generic field names and a few for each type of file (ie number, text, date, etc). This while on the client version I create the pdf and store it on the server via a share network file path. (works fine) I then take all the variables I need and pass to the server and create new (and only) record in the temp table. Now once on the server I go find the first and only record of this temp table and pick them back up on the server. (works fine)
Now I am able to send the email using the passed variables however, I am not getting the attachment the attachment to the email.
So on the client side I create the pdf. with
On the server side "Send Email" script step I use
and for that matter I even tried to directly link to the file to test but still fail to attach it to the email.
Where have I gone astray? It would seem to be a slam dunk directly naming the file but I still miss something.
What you need to remember is that server side scripts can also access data from 2 places.
The Temporary Directory ( a temporary directory is created every time a script is run )
The Documents Directory
So I would recommend you look at this blog post...
To understand how you could host a database where your externally stored containers would live in the Documents directory. That way when you attach the path its a path that your FileMaker script can have access to.
Well thank you for the article very helpful, I have been about to send the pdf to the documents directory and pick it up as the attachment on the email.
I thought I saw a Greg do an export field contents to automatically delete the file from the directory. Do you know the details?
Again thank you
Nope I do not know the details. Look forward to listening to Greg's talk when it is available.
Well, you can't directly export field contents for a container field, but you can via Base64 conversion and exporting the field as a text field and importing it and decoding it. Here is a quick example of doing that.
Set Variable [ $SP ; Value: Get ( ScriptParameter ) ]
If [ $SP = "Server" ]
Go to Layout [ “Test” (Test) ]
Enter Find Mode 
Set Field [ Test::Record ; 1 ]
Perform Find 
Set Variable [ $PDFBase64 ; Value: Base64Encode ( Test::Container ) ]
Set Field [ Test::Field ; $PDFBase64 ]
Set Variable [ $Path ; Value: Get ( DocumentsPath ) & "file.txt" ]
Export Records [ No dialog ; “$Path” ; Macintosh ]
Import Records [ No dialog ; “$Path” ; Add; Mac Roman ]
Set Variable [ $Container ; Value: Base64Decode ( Test::Field ; "statement.pdf" ) ]
Set Field [ Test::Container ; $Container ]
Exit Script [ Result: Get ( LastError ) ]
Perform Script on Server [ Wait for completion ; “Test” ; Parameter: "Server" ]
Show Custom Dialog [ Get ( ScriptResult ) ]
Deleting a file is as simple as exporting a file from a layout that has a zero count found set.
Once I have the file stored in the documents file of the server is it possible to pick it back up on the server side with a $variable in the server side script? (for attaching to the email)
It will pick up the file if I have it hard coded as the attachment name.
$variable does not seem to work for the file name
FMS can only touch files that are in the FMS documents folder. So if the file is not there it won't work...