9 Replies Latest reply on Aug 16, 2016 1:52 AM by paulwatts

    Exporting files from a Container Field

    paulwatts

      Hi all.

      I want to store files (WORD and XL) externally using a container field (one file per record) and want users to be able to download and open whichever file they select simply by clicking a button. I am trying to write a script to do this using the Export Field Contents step but am having difficulties. The solution will be hosted on FMS15.

       

      Issues:-

      1. If the users have FM Pro then I could specify a location for the file and get it to automatically open. However, I'm unclear about how to write the path as this would have to suit all users.

      2. Does the path have to include a file name? If so, why and does the file named have to exist or will the script step create it?

      3. How do I cope with both/either WORD and XL file formats?

      3. I have read that, if users are using WebDirect, the file downloads to a location specified by the web browser and I don't need to specify a path - is this correct and, if so, how do I get the file to open automatically?

      3. Does it make any difference to the answers above if I store externally open or externally secure?

       

      I would welcome your thoughts.

       

      Paul

        • 1. Re: Exporting files from a Container Field
          TSPigeon

          paulwatts:

           

          Thank you for your post!

           

          1. If the users have FM Pro then I could specify a location for the file and get it to automatically open. However, I'm unclear about how to write the path as this would have to suit all users.

          The Get(TemporaryPath) is a popular options for Export Field Contents and Open Automatically.

          2. Does the path have to include a file name? If so, why and does the file named have to exist or will the script step create it?

          It does need a file name. You can use GetContainerAttribute or name it based off of another field, if you know the file extension. You might see Exporting the field contents of a container field.

          3. How do I cope with both/either WORD and XL file formats?

          See Exporting the field contents of a container field.

          3. I have read that, if users are using WebDirect, the file downloads to a location specified by the web browser and I don't need to specify a path - is this correct and, if so, how do I get the file to open automatically?

          You will not need to specify the path for browser export. There also isn't a way to force it to open in this case (since it's dependent on the browser). After it is Downloaded/Saved their browser may ask if they'd like to open the file.

          3. Does it make any difference to the answers above if I store externally open or externally secure?

          Storing Open or Securely will not affect the ability to Export the Field Content.

           

          I hope this helps!

           

          TSPigeon

          FileMaker, Inc.

          3 of 3 people found this helpful
          • 2. Re: Exporting files from a Container Field
            paulwatts

            Thanks very much TSP for a very clear and concise reply (and not too technical).

            I will go ahead with the WebDirect approach and so will not need to specify the path/file.

            • 3. Re: Exporting files from a Container Field
              paulwatts

              However, I still need to know how to enable a user to export a file using FMPro.

              1. The user searches for a record with a specific file in the container field (the file might be WORD or XL).

              2. On finding it, he/she then wants to export this file using a button and script.

              3. The script would use the Export Field Contents step but must specify the location where the file is to be stored and file name under which it is to be stored.

              4. I still don't understand how to write the path to a known location and filename in the dialogue box. I have tried several times but failed for some reason. For example, if I use the path:-

               

              filewin:\C:\Users\Paul\Documents\FMexports

               

              I keep getting the message "FMfile.doc could not be created on this disc .........".

               

              5. I don't understand how the function Get(DesktopPath) helps.

              • 4. Re: Exporting files from a Container Field
                TSPigeon

                paulwatts:

                 

                Get(DesktopPath), Get(TemporaryPath), and some others are used to pull the path up to a certain point. Adding the File Name or using GetContainerAttribute (for "FileName") you end up with a valid path for export.

                 

                Simple Script for export:

                Set Variable [ $path ; Get(TemporaryPath) & GetContainerAttribute ( ContainerField ; "FileName" ) ]

                Export Field Contents [ ContainerField ; $path ; Automatically Open ]

                 

                You might see the Sample File "OpenContainerData.fmp12" I've attached.

                 

                TSPigeon

                FileMaker, Inc.

                • 5. Re: Exporting files from a Container Field
                  paulwatts

                  Thanks very much TSP!! I'm beginning to understand this process.

                   

                  However, there is one issue that I can't fathom. Logically, I want the user to select the container record who's file (contained therein) is to be exported to a specific location on the PC (is this location what the dialogue box calls the "Output file path"?).

                  1. How come your "$path" variable (which is used as the "Output file path") refers to a temporary path and to the container field and not to a specific location on the PC? Are you assuming that the user doesn't need to export to a specific location and can make do with a temporary location?

                  2. How do I make sure that the file is deposited to the exact location I want it to go to? My reason for doing this is to enable exported WORD and XL files to run an AutoOpen macro on opening that inserts a user-specific logo which resides in the same location.

                   

                  Paul

                  • 6. Re: Exporting files from a Container Field
                    beverly

                    Paul, the "issue" may be the write-permission that FileMaker would have to actually place the file in a location that the user chooses.

                     

                    Get ( DesktopPath ) & "CompanyFolder/"

                    would depend upon having that folder (directory) on each user's desktop.

                     

                    Do you have FileMaker Pro Advanced? If so, you may want to examine what the $path is returning. If not you can use the Variable in a Show Custom Dialog so that if you test on various user's machines, you would see what is actually returns. Just place the $path into the message. The script will pause to show the result when the script is run. You may find that the result is different for each person! So the Get() functions do some of the work.

                     

                    TemporaryPath is just what it means, only stored temporarily and not seen by the user

                    DesktopPath is the user's desktop directory (regardless of the platform)

                    ...

                    2 of 2 people found this helpful
                    • 7. Re: Exporting files from a Container Field
                      paulwatts

                      Hi Beverly.

                      Thanks for your response.

                      You appear to be strongly suggesting that I download the document to the users' Desktop location (and, hence, that I must have the logo image in that location for the AutoOpen macro to work)? Clearly, my idea would not work for an unknown location.

                       

                      As an alternative to using the Container file name attribute approach, would these script steps work:-

                      Set Variable [ $path ; Get(DesktopPath) & "FMfile" ]

                      Export Field Contents [ ContainerField ; $path ; Automatically Open ]

                       

                      where "FMfile" is the name I want to give the file in the Desktop directory/folder?

                       

                      Paul

                      • 8. Re: Exporting files from a Container Field
                        beverly

                        What about the extension of "FMfile"? you can name it what your computer will allow for filenames, but the extension is likely vital to allowing it to open (regardless of platform).

                        .pdf, .csv, .txt, .htm, .doc, .jpg

                        beverly

                        • 9. Re: Exporting files from a Container Field
                          paulwatts

                          Okey dokey and thanks. You know, I think I know what I'm doing now (at least on this issue)!!

                           

                          Paul