2 Replies Latest reply on Jun 1, 2015 8:41 PM by philmodjunk

    Export all photos from container

    BenT

      Title

      Export all photos from container

      Post

      Hey all,

      So for the sake of understanding, I've got three values: PictureID, PictureLarge (the container), and ScanID.

             
      • Picture ID is a newly generated number with each picture. 
      •      
      • PictureLarge is the container housing the entire image
      •      
      • ScanID is a 6 digit identifier that represents one item

      The idea here is that in order to have multiple pictures on one item, but for them to be related, the ScanID must be the same.

      For example, say I have 3 ScanID's, and thus 3 products. Each ScanID has multiple "PictureLarge" containers equal to the amount of photos stored for that item. Again, each picture has a unique PictureID. All of these are contained within their own table called "Pictures" ... where "ScanID" is related to the other tables in our database.

      I've been writing a script that would allow someone to export all of the photos (PictureLarge), from one ScanID into a folder on the desktop called "FMExports", with a subfolder being the ScanID, and the filename being the unique PictureID.

      I've attached a photo of what my script looks like thus far.

      You'll notice at the top I have a value "Scans:ScanID" ... this is the relational value to "Pictures:ScanID". My thinking was that I could run a loop statement setting the $check variable to the active ScanID (which item am I looking at with all the pictures?), then when the script ran, it would end if the ScanID went to the next product.

      A little more details:

      In the one example I'm working with, I have three products, 213506, 213507, 213508. The first item has no pictures. The second, has 9, and the last one, 15. 

      If I run the script while looking at the first item, with no pictures, it exports to the 213508 folder with the first 7 pictures. I suspect this is because the view that the script changes to shows all 24 records, and doesn't have the photos sorted by ScanID. If I run the script on the second ScanID, it exports all 9 photos nicely. If I run it on the third ScanID, it only exports 7 - again, I suspect because the list isn't sorted. 

      Any suggestions? Should I redo the "If" statement to run through all the photo records (in this case, 24), and only export if Scans:ScanID=Pictures:ScanID?

       

      Screen_Shot_2015-06-01_at_3.29.14_PM.png

        • 1. Re: Export all photos from container
          BenT

          Wanted to share that I figured it out myself. I'm sure my coding isn't very pretty, but it works. Essentially all I did was sort the records, and add an IF statement to check if the ScanID matched the Picture:ScanID I wanted exported.

          I've attached the finished script below.

          • 2. Re: Export all photos from container
            philmodjunk

            When using Go To Related Records to pull up a found set of related records on another layout, you need to either check immediately before to see if there are any related records to go to (IsEmpty ( RelatedTable::ForeignKey ) will be true if there are no related records) or you would check for an error code immediately after. If there are no related records, no layout change takes place the script advances to the next step just as though the Go To Related Records step did not exist.