5 Replies Latest reply on Jul 8, 2011 11:49 AM by philmodjunk

    Previous and Next Image Buttons (redux)

    DavidRuggles

      Title

      Previous and Next Image Buttons (redux)

      Post

      As I mentioned in my previous post Previous and Next Image Buttons I'm trying to implement previous/next buttons for images from a related database based on this post Portal with one container for multi images

      With a little help I was able to get the image to display, but the next code isn't working:

      Freeze Window
      Go To Layout ["Photos" (Photos)]
      Go To Record/Request/Page [Next]
      Set Variable [$$PhotoID ; Value:Photos::id]
      Go To Layout [original layout]
      Refresh Window [Flush cached join results]

      I can manually set $$ImageID to a valid id (for a specific record) and it will work, (i.e. Set Variable [$$PhotoID ; Value: 6]) but the above code always returns the first image. Any suggestions, or steps to troubleshoot?

        • 1. Re: Previous and Next Image Buttons (redux)
          philmodjunk

          If you don't have FileMaker Advanced, add a pause/resume step right after the first Go To Layout step to see what record is the current record and what records make up the found set. This method assumes that you can set up a found set of portal records in a hidden layout that cannot then be altered by other scripts or user actions. Sometimes this requires a special, separate table occurrence and layout to keep other actions from altering the found set used for controlling your portal.

          If you have Advanced, enable the script debugger and step through it.

          • 2. Re: Previous and Next Image Buttons (redux)
            DavidRuggles

            Ok, here's how I modified the script:

            Freeze Window
            Go to Layout [“Photos” (Photos)]
            Pause/Resume Script [Indefinitely]
            Go to Record/Request/Page [Next]
            Pause/Resume Script[Indefinitely]
            Show Custom Dialog [Title:"Value"; Message: $$PhotoID; Buttons:“OK”,“Cancel”]
            Set Variable [$$PhotoID; Value:Photos::id]
            Show Custom Dialog[Title:"Value"; Message: $$PhotoID; Buttons:“OK”,“Cancel”]
            Go to Layout [original layout]
            Show Custom Dialog [Title:"Value"; Message: $$PhotoID; Buttons:“OK”,“Cancel”]
            Refresh Window [Flush cached join results]

            I saw that it stepped through correctly and changed the value of $$PhotoID, but after the Go to Layout [original layout] the value of $$PhotoID reverted to the previous value. I further modified the script:

            Freeze WindowGo to Layout[“Photos” (Photos)]
            Pause/Resume Script[Indefinitely]
            Go to Record/Request/Page[Next]
            Pause/Resume Script[Indefinitely]
            Set Variable[$ThisPhotoID; Value:Photos::id]
            Show Custom Dialog[Title:"Value"; Message: $ThisPhotoID; Buttons:“OK”,“Cancel”]
            Go to Layout[original layout]
            Show Custom Dialog[Title:"Value"; Message: $ThisPhotoID; Buttons:“OK”,“Cancel”]
            Set Variable[$$PhotoID; Value:$ThisPhotoID]
            Show Custom Dialog[Title:"Value"; Message: $$PhotoID; Buttons:“OK”,“Cancel”]
            Refresh Window[Flush cached join results]

            Which worked fine, except that when it goes to the layout it's always on the first record, so I added an initial step:

            Freeze Window
            Go to Layout[“Photos” (Photos)]
            Loop
              Go to Field[Photos::id]
              Show Custom Dialog [Title:"Value"; Message: Get ( ActiveFieldContents ); Buttons:“OK”,“Cancel”]
              Exit Loop If[Get ( ActiveFieldContents ) = $$PhotoID]
              Go to Record/Request/Page[Next]
            End Loop
            Pause/Resume Script[Indefinitely]
            Go to Record/Request/Page[Next]
            Pause/Resume Script [Indefinitely]
            Set Variable[$ThisPhotoID; Value:Photos::id]
            Show Custom Dialog[Title:"Value"; Message: $ThisPhotoID; Buttons:“OK”,“Cancel”]
            Go to Layout[original layout]
            Show Custom Dialog[Title:"Value"; Message: $ThisPhotoID; Buttons:“OK”,“Cancel”]
            Set Variable[$$PhotoID; Value:$ThisPhotoID]
            Show Custom Dialog[Title:"Value"; Message: $$PhotoID; Buttons:“OK”,“Cancel”]
            Refresh Window[Flush cached join results]

            It seems like this is getting overly complicated, is there a better way to do it? At least I'm making progress...

            • 3. Re: Previous and Next Image Buttons (redux)
              philmodjunk

              You've got something else involved here. I'd suspect a script trigger controlled script is modifying the value of $$PhotoID after you return to the original layout.

              In layout setup on the original layout, what script triggers are specified and what scripts do they perform?

              • 4. Re: Previous and Next Image Buttons (redux)
                DavidRuggles

                The script is the set image script detailed in this post: Previous and Next Image Buttons (I don't have any other scripts or triggers yet)

                I assume setting the $$TriggersOff variable from that post in this script will do the trick? Is that also probably what's resetting the record location?

                • 5. Re: Previous and Next Image Buttons (redux)
                  philmodjunk

                  Yep, that's it. You need to set that variable to true at the beginning of the script and set it to False at the end to keep the layout's script trigger from performing a script that changes your current record and assigns the ID of that first record to your other variable.