1 2 Previous Next 26 Replies Latest reply on Jul 12, 2014 8:08 AM by user9259

    Saving as PDF on a server hosted solution

    peteraddison

      I have FM 12 server. Multiple clients, various OS.

       

      I want to export to PDF automatically with a named pdf to a folder on the network. This could be a subfolder in the databases folder, but nothing I've done seems to work, resulting in:

       

      ""123XYZ.pdf" could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk."

       

      I created the subfolder and if I open with FMPro the filemaker file that is in that folder I can make the 'save' work, so I know the permissions are good. I've added "fmserver" to the permissions for good measure.

       

      When I open the file with server and access "remotely" it fails with that error.

       

      path is file:Invoices/$invoice where $invoice is the number of the invoice. and file:Invoices/ is a subfolder in the directory of the hosted file.

       

      I've also tried other paths such as filemac:/MacintoshRD/Invoices/$Invoice and other network locations.

       

      where /MacintoshRD/Invoices is the name of a folder on my root directory with permissions set to read-write

       

      It would seem to me that this export script will not work with a hosted solution, but I'd love to be educated otherwise.

       

      My alternative seems to be to force the user to save the pdf manually and choose the path at that time, which seems quite lame.

       

      Advice?

       

      Thanks! Peter

        • 1. Re: Saving as PDF on a server hosted solution
          DavidZakary

          That error is generally seen when the path is incorrect. I'd hunt around in the code where you're creating the path.

          • 2. Re: Saving as PDF on a server hosted solution
            peteraddison

            path works when unhosted, how do I need to change the path for hosting?

             

            procedure:

             

            turn off server, open file with FM Pro .. test ... works

             

            open file with server .. open 'remote' with Pro .. test .. fails.

            • 3. Re: Saving as PDF on a server hosted solution
              ch0c0halic

              peteraddison,

               

              You'll have to provide the actual calculation you use to generate the path. It should be using the "Get ( DocumentsPath )" function. THat returns an entirely different location for FMS that your User account. If you hard coded any part of the path that is not in the FMS Documents folder then it can't work.

              • 4. Re: Saving as PDF on a server hosted solution
                peteraddison

                I did provide it:

                 

                path is

                file:Invoices/$invoice

                 

                where "$invoice" is the number of the invoice. and "file:Invoices/" is a subfolder in the directory of the hosted file (ie: in the library subfolders where server lives).

                 

                full path for that would be:

                 

                MacintoshRD/Library/Filemaker Server/Data/Databases/Solution/Invoices/

                 

                I have successfully made it save into the LOCAL fm Pro directory (ie on the user's machine), or a subdirectory of that but I can't seem to figure out what path might work to move that to a server folder where everyone can see the same folder.

                 

                I'll look at that Get function.

                • 5. Re: Saving as PDF on a server hosted solution
                  peteraddison

                  Get(DocumentsPath) & "/Databases/Integrator/Invoices/"&Orders::InvMemNo&".pdf"

                   

                  Does NOT work. but would seem to be what I want give it, based on the description in the HELP for the Get function:

                   

                  "

                  When running on FileMaker Server, Get(DocumentsPath) returns the location of the Documents folder, which is in the same folder as the server's Backups, Databases, and Scripts folders. The Documents folder is used as a shared location that scripts from different sessions or other processes on the machine can use to import or export files."

                   

                  I put that in a variable named $Invoice and used the variable as the path in the export command.

                  • 6. Re: Saving as PDF on a server hosted solution
                    peteraddison

                    FYI the Get function is returning the user's documents folder, not the FMS document folder as indicated by help; that's got to be the issue.

                     

                    I created a custom dialog to display it.

                    • 7. Re: Saving as PDF on a server hosted solution
                      ch0c0halic

                      peteraddison,

                       

                      When the script is run on the FMS it returns the FMS Document folder. When you run it as the User then it returns the user account's document folder. Its all a matter of what user account the script is running under. When FMS is running it then it is using the fmsadmin account.

                      • 8. Re: Saving as PDF on a server hosted solution
                        ch0c0halic

                        peteraddison,

                         

                        Since calculation operations are not allowed in the Path field, it doesn't do calculation engine operations, it can't work.

                         

                        file:Invoices/$invoice

                         

                         

                        You need to do it as a real calculation in the Set Variable[] script step.

                         

                        Set Variable [ $path ; "file:/" & Get ( DocumentPath ) & $myFileName & ".pdf" ]

                         

                        Then you use ONLY the variable "$path" when setting the value for file location.

                        • 9. Re: Saving as PDF on a server hosted solution
                          peteraddison

                          chocolhalic:

                           

                          I can make this work the way I want IF I can point the save (and retrieve, I want to put this in an email after) to the Server's folder.

                           

                          I think the step or funtionality I'm missing is:

                           

                          how do I "run this under the server" and not the user.

                           

                          If put in your suggested code, and access the remotely hosted script, it points to my local documents folder.

                           

                          in other words: I run the server-hosted script on my local machine "save as pdf to $path" in your example, the file arrives on my local machine.

                           

                          Your instructions (and thank you so much) would seem to indicate that if I run this as a client to the hosted machine, the Get(DocumentPath) should make the file save on the host computer, but that does not happen.

                           

                          Somehow I have to make the *server* run the script and not the client? How?

                           

                          /me runs to find a box of Roger's Victoria Creme chocolates as a reward

                          • 10. Re: Saving as PDF on a server hosted solution
                            BruceRobertson

                            You can't run the script as a server script. Save as PDF is not a server-compatible script step.

                            • 11. Re: Saving as PDF on a server hosted solution
                              ch0c0halic

                              Bruce,

                               

                              Thanks for bringing a little sanity to my zeal. I totally missed that in the original post.

                               

                              All script steps used in the script must be server compatible. Be sure to change the "Show Compatibility" in the lower left corner of the scripts dialog to "Server" so it grays out unusable script steps.

                               

                              peteraddison,

                              However, to explain "running a script on FMS".

                              In order to run the script on FMS you must set up a scheduled event. This tells the FMS which script to run, what FMP account to use, and when to run it. When running as a scheduled event it runs on FMS using the fmsadmin account. That restricts the locations to the ones FMS has access to. For security reasons FMS does not have access to remote volumes.

                              • 12. Re: Saving as PDF on a server hosted solution
                                peteraddison

                                Bruce's answer is technically the correct one. I created a work-around with Choc's advice.

                                 

                                I'll summarize the situation for others that may be looking at this in future:

                                 

                                I can't save the file on the server's network volume as I had wished, due to the fact that FMS does not have access to server volumes for security reasons.

                                 

                                When I turned on compatibility view, save as PDF greyed out for server, but it does, actually work for me.

                                 

                                I made a folder in the user's local-machine documents folder named "Invoices"

                                I made a variable for the file's name: $Invoice with the calculation: Orders::InvMemNo&"-"&Customer::ShortName&".pdf"

                                I made a global varialbe for the path to the user's local drive: $$InvoicePath with the calculation: Get ( DocumentsPath )&"Invoices/"&$Invoice

                                 

                                This saved the file with the invoice number and name of client on the user's local home folder in the subfolder "Invoices"

                                 

                                I used a global Variable so that I could use it in an optional email script. The email script used the "Attach File" function and called that same variable as the path: $$InvoicePath . This pulled the specifically named invoice from that folder.

                                 

                                This created an email with boiler-plate body text and other particulars and the specific invoice attached.

                                 

                                The one funtionality I did not achieve with this was to have that invoice document saved on a networked folder so that all users would place their invoices in the same folder. My "work-around" for this is to have them move the entire contents of the "Invoices" folder to the network drive at the end of the day. One could use an automator script or batch file for this to be automated, but that would need to be set up on each workstation.

                                • 13. Re: Saving as PDF on a server hosted solution
                                  BruceRobertson

                                  "When I turned on compatibility view, save as PDF greyed out for server, but it does, actually work for me."

                                   

                                  Actually; no. You didn't write a server script. You wrote on conventional script run by the user.

                                   

                                  A server script is one that is run by the server, with no user interaction, according to a schedule set up on the server.

                                  • 14. Re: Saving as PDF on a server hosted solution
                                    BruceRobertson

                                    You could have set up the system to use FileMaker container fields. Then the invoices would be immediately available to all users. No need to export to the user's desktop, no need for automator, no need to wait.

                                    1 of 1 people found this helpful
                                    1 2 Previous Next