3 Replies Latest reply on Jul 12, 2015 6:33 AM by philmodjunk

    Opening a PDF from a container field

    PaulTraub

      Title

      Opening a PDF from a container field

      Post

      Hi,

      I'm hoping that someone is able to shed some light on this. I have 10 container fields that I drop insert docs into. These for now reside on my laptop as I will only migrate the full program to our server when it's complete and well tested.

      I use a script to insert the files which are mainly pdf's  into each container field and that works well. I have set to reference the file externally. The issue is that it does open the file initially, but after closing and opening the program it brings up an error "The file XXXX.pdf could not be found and is required to complete this operation" I have tried using internal storage but get the same error - it's driving me nuts and is the only stumbling block so far. Added to that is if the document name contains spaces then it always gives the above error. But that's an easy fix by using underscores in place of spaces.

      The script that I use to open the file is the SEND EVENT and then a calculation. I'm on a windows machine.

      I really just don't want to put the full path in a script manually as this may change from time to time.

      Oh, the location of all the pdf files are constant, so I would assume (I know it's dangerous :) ) that it would always reference that location.

      Any help would be great.

      TIA,

      Paul 

       

      1.PNG

        • 1. Re: Opening a PDF from a container field
          philmodjunk

          I'd need to see the calculation that you are using before I can suggest why it might fail, but opening the files from a remote storage location is not generally a good idea.

          Export Field Contents can open a copy of the file on the local machine. You can use Get ( TemporaryPath ) to specify a location for exporting/opening the file to a standardized location that will work on any computer and which is a location where the file copies will not be retained afterwards.

          Also, you can use an interactive container field and open the file in a large format container field and not need to open the PDF in a separate window.

          • 2. Re: Opening a PDF from a container field
            PaulTraub

            Hi Phil,

            Thanks for the reply. I'm reasonably new to FM after a break since Ver 5 !! I am now very rusty with scripts and everything is taking ages.. perhaps it's the age :)

            Anyways, it would be greatly appreciated if you could perhaps also include the correct script steps for each method of attaining the result. Thanks so much

            Paul

             

            • 3. Re: Opening a PDF from a container field
              philmodjunk

              The text returned from a container field varies with the insertion method used and the storage option specified for the field. Simply referring to the container field is not guaranteed to produce a file path and even if it does, it may not be producing a file path that is valid for the current user's machine as a location on a server would need to be mapped and at least "read" access permission granted to that user. One of the reasons to use remote storage is to avoid the need to share the directory in such fashion

              Set Variable [$Path ; value: Get ( TemporaryPath ) & "FileName.PDF" ]
              Export Field Contents [ Jobs::G_Schematic_1 ; “$Path” ; automatically Open ]

              Is a method for opening your PDF on the local users machine while using the temporary folder as the location to which to export the copy such that you don't end up with a bunch of file copies cluttering up your local user's machine. In place of "filename.PDF", you can use a calculation that extracts the file name from the container field though you might have a text field that separately stores the file name and then you can use that or you can use just static quoted text like I have in this example.

              For more on FilePaths, container fields and the script steps that use them see: Exploring the use of a $Path Variable in Scripts

              There's a file that you can download from there that you can use to explore filepaths and it includes a calculation designed to extract file names from a container field no matter what storage option or insertion method.