5 Replies Latest reply on Jun 14, 2016 1:26 PM by StephenWonfor

    Trouble exporting images from a container field

    sotura

      I'm working on a Script to export images from a container all at once and i got most of my framework from the

      "Exporting the field contents of a container field" page Exporting the field contents of a container field | FileMaker

       

      The problem I'm running into is that the script appears to be running but i cannot find the files that its exporting because it doesn't actually appear to be saving the files to any specific location. I have checked the desktop and documents folders and I have found nothing. Here is the script that I am running with the following values

      Table: Inventory

      Inventory::EquipmentRecordID == description

      Inventory::Image | Container Main

       

       

      Go to Record/Request/Page [First]

      Loop

           Set Variable [$filePath; Value:

      Choose ( Abs ( Get ( SystemPlatform ) ) -1 ;

       

       

           /*MAC OS X*/

           Get ( DesktopPath ) & Inventory::EquipmentRecordID & ".jpg"

      ;

           /*WINDOWS*/

           "filewin:"& Get ( DocumentsPath ) & Inventory::EquipmentRecordID & ".jpg"

      )

      ]

         Export Field Contents [Inventory::Image | Container Main; " $filepath”] 

             Go to Record/Request/Page [Next; Exit after last]

      End Loop

       

      I don't understand what the $filepath is doing I believe its a placeholder for my actual filepath but whenever I attempt to enter in a filepath location like filewin:/C:/users/... etc. it returns errors that it contains unusable symbols

        • 1. Re: Trouble exporting images from a container field
          user19752

          Do you use FM15? I noticed it lies creation data of exported file as same as original file, on Windows.

          • 2. Re: Trouble exporting images from a container field
            keywords

            Re: "I don't understand what the $filepath is doing I believe its a placeholder for my actual file path"—

            $filepath is a variable which you should declare at the top of your export script. It needs to include all the relevant elements you see here in the example part of the Specify Output File dialog, which you will access under the Export Field Contents script step:

            Screen Shot 2016-06-14 at 9.46.10 AM.png

             

            •   The following path which I declared as the variable $exportFilepath, results in a file named TEST.pdf on my desktop: "filemac:" & Get ( DesktopPath ) & "TEST.pdf"

            •   As you can see, the first and last parts of the variable are hardcoded text, while the middle is a FM function. I suggest you experiment using Get ( DesktopPath ) to begin with, to help you understand, then maybe move to adding a folder to your desktop and adding that to your variable to make it one step more complex. Once you successfully achieve that you'll be well on your way.

            •   As you can also see, in the Specify Output File, all you need to enter is the name of the variable and FM will do the rest—as long as your variable is properly declared.

            •   The essential steps in your script are the following:

            Set Variable [ $exportFilepath; Value:"filemac:" & Get ( DesktopPath ) & "TEST.pdf" ]

            Export Field Contents [ TEST::containerTEST; “$exportFilepath” ]

            Exit Script [ ]

            In the first line you declare the variable

            In the second line you specify the field to be exported and use the variable to set the export path, and the actual export takes place.

            Those are the essential two steps which must be performed in that order. The script could of course do other stuff as well—for example, if you wanted to use it in a loop to export a series of files you would have to use FM functions, not hardcoding, to name your exported files (in fact it is better to do that in any case; I just used hardcoding for simplicity).

             

            If you have FMAdvanced, I suggest you use the Debugger to step through the script with the Data Viewer open so that you can see what is happening at each step.

            • 3. Re: Trouble exporting images from a container field
              user19752

              I typo, "creation date". Then I couldn't find the exported file some while, since I find latest file always.

              • 4. Re: Trouble exporting images from a container field
                sotura

                Thank you for the great advice! With your help I got it to work. My new question would be how would I write this script to send the file to a folder on the desktop? would i use the  "/" notation like on windows for example "get ( DesktopPath/testfolder ) " i am unsure how this would work since Get ( Desktop ) is a function of FM

                • 5. Re: Trouble exporting images from a container field
                  StephenWonfor

                  Hi

                   

                  Get(DesktopPath) & "SomeFolder/"


                  Stephen

                  1 of 1 people found this helpful