6 Replies Latest reply on Jun 18, 2013 1:10 AM by RickDearden

    Saving records to a PDF into a server path

    RickDearden

      Title

      Saving records to a PDF into a server path

      Post

           Hi all,

           First post here so here goes!

           I have a field, DOCSPATH, the value of which is a copy/paste of a server path.

           For this example it's "\\SERVER\Documents\Folder"

           My script sets the variable $docspath to equal the field DOCSPATH

           When saving the records to a PDF I use the variable $docspath as the location to save to. 

           I keep getting a message saying "\\SERVER\Documents\Folder\filename.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.

           There is enough space on the disk, the user has the appropriate privelages/etc but still it doesnt work.

           When I try and save to the desktop path this works fine so I'm a bit stumped as to what's causing the issue when I add the server path into the equation.

           I was initially thinking that the slashes were the wrong way round (as the filepath normally looks something like filewin:/c:/desktop /etc. but don't know if this would make any difference). If it does and this is the answer how do I change the slashes to the other directon in the script (as my DOCSPATH field is consistant throughout my DB and also opens explorer windows according to the path set - so I can't change it on that.

           I've also tried having "filewin:/" & $docspath & "/filename.pdf" to the box but still get the same error message.

           Anyone have any ideas!?

           Thanks in advance...

           Rick.

        • 1. Re: Saving records to a PDF into a server path
          RickDearden

               Edit to add:

               I've just tried it by hardcoding the following in and it works so it looks like it's a 'slash direction' problem!

               filewin://SERVER/Documents/Folder/filename.pdf

               Is there any way to automate the task of changing from / to \ ?

               Rick.

          • 2. Re: Saving records to a PDF into a server path
            philmodjunk

                 Are you performing this script from a client machine or via a server schedule?

                 Are you sure that this file path is valid?

                 What OS are you using?

                 Is the shared directory to which this path points mounted/mapped and does the current user have "write" permission to write to this directory?

                 And some older versions of Filemaker may require that you use "file:\\SERVER\Documents\Folder"

                 and in windows, there'd need to be a drive letter there--one mapped to the current user's machine and whether you map the drive letter to Server or Documents

                 One trick for getting a correct file path is to insert a file from the desired location "by reference" into a container field and then you can extract a valid file path from the container field. THis thread has a download link for a file set up so that you need only insert a file from the desired location to see the file path to the file's location: Exploring the use of a $Path Variable in Scripts

            • 3. Re: Saving records to a PDF into a server path
              RickDearden

                   Hi Phil,

                   From a client machine connected to the network as Admin with full read/write permissions.

                    

                   The filepath is valid (see above - I think it crossed over with you posting)...

                   Windows 7 / Filemaker 12

                   I'm sure it's just a slash direction issue!

              • 4. Re: Saving records to a PDF into a server path

                     I am attempting to do a similar thing but with a mac osx. I currently had the line below in my script which would export a record as a pdf and put the pdf into a file called "enquiries" that is located on my desktop. The pdf file is automatically named after the Enquiry name and order number - e.g. Smith/1000.pdf.

                     Set Variable:

                     Name

                     $Path

                     Value:

                     "file:" & Get (DesktopPath ) & "Enquiries"  & "/" & Invoiceitems_INVOICEDETAILS::Enquiry_Name & "/" & Invoiceitems_INVOICEDETAILS::fk_Order & ".PDF"

                      

                     However, Now I want to export this file to a folder in my documents folder on my new mac server and unsure how do do this. I have already implemented a way to create folders from FM12 to the server using applescript but am now stuck with implementing an export from a script...Help on this would be hugely appreciated as have already pulled out remaing hair overcoming the fodler creation on server issue!

                • 5. Re: Saving records to a PDF into a server path
                  philmodjunk

                       You can use the substitute function to replace "\" with "/"

                       Substitute ( yourField ; "\\" ; "/" )

                       the extra \ is needed as \ functions as the "escape" character within quoted text and thus you need to "escape the escape character" to get it to be perceived as the backslash.

                  • 6. Re: Saving records to a PDF into a server path
                    RickDearden

                         Worked like a dream that Phil!

                         Problem solved and all is good with the world once more ;-)

                         Thank you so much!