4 Replies Latest reply on Jul 28, 2015 4:14 PM by RobertMoss

    Portal with one container for multi images



      Portal with one container for multi images


      Problem Solved: file with an image container to show images one at a time where there are a varying number of images per record.

      I just switched from FileMaker 6 to FM Pro 11 and one solution didn't quite update properly. This one has a table (related daughter file in FM6) that is images only to be able to display varying number of images in each record of the parent file. Each record in the daughter file has a number field that relates to the parent file, a container for an image and a serial number field unique for each record, also related to the parent file. The images are shown on the matching record (linked through the number) in the parent file on a portal. There is a field on the parent that shows the total number of images for the record and one that shows which image is currently being shown (i.e. 2 of 5, or 1 of 7). There are two buttons to move to Next or Previous image. A script for each button uses Set Field (Current Row), Current Row + or - 1, and Go To Portal Row... . to move up and down in the images. The Relations are in the main file linking the number to the number field of the image table of the daughter file and the second one linking the serial number to the serial number in the daughter file.

      This works perfectly, and was done from suggestions from this forum many years ago when FM6 was current. Oddly, this only works if the image container field in the parent file sits on the main window, not on the portal (which I shrunk down to an inconspicuous dot).

      After converting this solution to FM 11, the buttons would not work to navigate to Next or Previous image, or show an image. By tweaking a couple things, I got the first image to show, but couldn't change to the next one. The scripts were correct and the relations were correct. As many of you know the process, what followed were many hours over a few days trying to find the problem. There were scarce few messages in forums addressing showing multiple images in one field, and none offered a solution.

      Finally, yesterday I found the solution in this forum in a message that did this with a different method, the portal must have a vertical scroll bar. In the conversion of the file from 6 to 11, this was not created and I continued to overlook that point. Also, the relationship of the serial number field had to be changed, from linking directly from the parent table to the one table in the daughter file to making that link to a copy of the table.

      The latter point I discovered by accident/trial and error. Reading messages and the Users Guide, there was mention of needing to use a self join for similar situations involving inventory to sales, etc. I tried a self join and was awarded with a copy of the table in the daughter file. Still couldn't make it work. Finally, by deleting the self join, but linking the parent serial number field to the serial number field in the copy of the table in the daughter file, it works, and unlike in the FM6 file, the image field can be properly placed on the portal window.

      I just thought some of you might be interested and if anyone needs another solution to show a selected image on a parent file from a varying amount of images in a daughter file (or I assume table in the parent (and only) file, which is a new concept to me having only worked with FM6 with separate files) then let me know and I will post the button scripts and all information.

      Now I have to be brave and move the daughter file records to a table in the parent file to be modern and up to date.


        • 1. Re: Portal with one container for multi images

          Just so you know, using a scroll bar is not the only way to do this. If you want to use a pair of buttons to move through the related image records, that approach can be implemented.

          • 2. Re: Portal with one container for multi images

            Thanks, If you can provide another method, please do. I'm interested in anything that works better, easier or just different because it might be handy "next time." I do have a need for another file with a similar setup.

            I don't do enough work with Filemaker to be an expert, so depend on others for more complex methods like this.

            Thank you.


            • 3. Re: Portal with one container for multi images

              There are a number of possible variations. Each require a script that acquires an ID number of the next or previous related record and then updates either a global field used in a relationship or a portal filter to display the next/previous image.

              Say you have this relationship:

              Main::MainID = Images::MainID

              In FileMaker 11, you can use a portal filter:

              Place a portal to Images on your Main layout.

              Define this Portal Filter:

              $$ImageID = Images::ImageID

              Write this script to initialize $$ImageID when the On RecordLoad trigger is tripped:

              IF [ Not IsEmpty ( Images::ImageID ) /* There are related images */ ]
                  Freeze Window
                  Go To Related Record [ show only related records; From Table: Images ; Using Layout: "Images" (Images) ]
                  Go To Record [First]
                  Set Variable [$$ImageID ; Value: Images::ImageID]
                  Go To Layout [original layout]
                  Refresh Window [Flush cached join results]
              End If

              Here's the script for "Next Image"

              Freeze Window
              Go To Layout ["Images" (Images)]
              Go To Record [Next]
              Set Variable [$$ImageID ; Value: Images::ImageID]
              Go To Layout [original layout]
              Refresh Window [Flush cached join results]

              The script for "Previous Image" will be nearly identical except that the go to record step will go to the previous record instead of the next record.

              • 4. Re: Portal with one container for multi images

                Hi Phil,

                I found your post regarding using one portal for displaying multiple images from a related table at the following link:Portal with one container for multi images

                This is not working for me for some reason, however I know this is the best solution so I decided to message you personally. I have the following questions:

                1. The On RecordLoad script trigger should be set up on the "Images" layout and not on the "Main" layout, correct?
                2. What sort of field must the "ImageID" field be? As of now, I have a serial number on creation. 
                3. Must the portal in the "Main" layout contain a container field inside from the "Images" table?

                For some reason, the scripts we are using are only referencing the very first record in the "Images" table, and not the related records for the record we are currently on in the "Main" layout. Furthermore, when we click the "Next" button, it continues to reference the very first record in that table.

                Any advice would be greatly appreciated.

                - mossr