6 Replies Latest reply on Dec 27, 2014 10:43 AM by philmodjunk

    Selecting Images from a Portal



      Selecting Images from a Portal


      I am using a portal that contains images based on a drop-down menu (Tires, Doors, Windows, etc.).  When I choose Tires from the drop-down menu, only the Tire images appear on the portal.  Is it possible when an image on the portal is displayed, I can choose that image (clicking it) and the name of the image it is copied to a separate field.

        • 1. Re: Selecting Images from a Portal

          But you don't have to actually copy the image and here in the FM GO forum, we tap things rather than "click" them wink

          Since you have a series of related records, you can set up the field as a button that performs a script. That script could copy the container field value to a container field on your layout. But it can also just copy the value of a primary key value to a different field in your layout's record that then serves to link via a different relationship to just that one portal record--which makes it possible to display the image and any other data--such as a name from that same record.

          • 2. Re: Selecting Images from a Portal


            You are correct - a tap will do...

            I tried writing a script (see attached) to copy the image (at first I tried a script to copy the model no.).  But the script stops at the image - outlined in blue.

            • 3. Re: Selecting Images from a Portal


              Sorry, one more thing.  I tried using a script to tap the image, but didn't know what event to assign the script to.

              • 4. Re: Selecting Images from a Portal

                Copy is not a good option for moving data around within FileMaker. It will replace any data the user may have copied with the data copied by the script and this can confuse and irritate the user. There are better ways to move data around.

                Say that you have this relationship for your portal:

                LayoutTable::ProductType = Products::ProductType

                With your layout based on LayoutTable and your portal a portal to Products.

                Go to Manage | Database | Relationships and use the duplicate button (two plus signs) to make a copy of the Products Tutorial: What are Table Occurrences?. Link in the new occurrence like this:

                LayoutTable::SelectedProduct = ProductSelected::ModelNumber

                Add the container field from ProductSelected to your layout.

                and then this script can be the script performed by clicking a button in your portal row:

                Set Field [LayoutTable::SelectedProduct ; Products::ModelNumber

                Note:  In layout mode, you can select an object such as the container field in your portal and use button Setup in the Format menu to turn it into a button that performs a script when tapped/clicked. 

                When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                • 5. Re: Selecting Images from a Portal


                  As my teenage son would say, “you are the bomb…”  This works great.

                  In principle, it is “pasting” the information into the desired field/container?

                  • 6. Re: Selecting Images from a Portal

                    This script does not paste any data into any container. It simply links the current layout to the selected record via a second relationship.

                    Set Field does do a kind of copy/paste. It works here as the "context" is correct both for the target field (the first parameter) and the fields referenced in the calculated result (the second parameter).

                    In other situations where this is not the case you can use code such as this in place of copy/paste:

                    Set Variable [$Variable ; value: SomeTable::SomeField ]  ---> This in place of "copy"
                    Go to layout ["Another table" (AnotherTable)] ---> change context
                    Set Field [AnotherTable::Field ; $Variable ] ----> This in place of "paste"

                    Not only does this leave the clipboard intact, it also does not require that "SomeField" and "Field" be physically present on the current layout in order for this to work. With copy, paste, clear, and the script steps that start with the keyword "insert". The steps silently fail to work. Thus you can have a perfectly working system until, several months later after you've forgotten some design details, you modify a layout by removing one of these fields and then your script mysteriously fails to work as it did before...