4 Replies Latest reply on Jan 5, 2012 1:56 AM by brynley

    Popup Menu to change layouts/Script Triggers?

    brynley

      Evening all,

       

      I have a solution that has a lot of buttons to navigate to different sections of the solution. But there are quite a few sections thus lots of potential buttons.

       

      I have created a Popup Menu (global in a globals file) in each layout that has the list of sections (layouts) defined in a Value List. I have a Script Trigger attached (on modify) and the script basically says:

       

      if gLayoutChoose = "Clients"

      go to Layout "Clients

      set field gLayoutChoose "Clients" ((**This is done to ensure that the gLayoutChoose always contains a value and is not blank - this is the main issue)

      else if ...

      ...

      ...

      end

       

      Which works...sort of...

       

      There are 2 issues I am having - the first is that the gLayoutChoose does not "hold" the current value. So sometimes the user sees a blank default menu (therefore they say "oh click in the white part?") - doh! If they click it they see the standard values I want them to see - it is just annoying that it does not stay stuck!

       

      Second as there are a number of layouts the if-else-if script is getting rather long! (altho this is not a real concern - but i bet there is a "smarter way" of handling this)

       

      This pop-up menu will suit the purpose really well - if I can get it working!

       

      I did see an example file several yrs ago that did this and worked - can I find? Can I hell is like! John Mark Osborne does one that uses a pop-up list (not a menu) and a "go to" button. But a pop-up menu would suit better.

       

      If anyone can stop me from drinking cheap wine by the cask...

       

      Guidance would be appreciated....

       

      Brynley

        • 1. Re: Popup Menu to change layouts/Script Triggers?
          MikeMcErlean

          Hi Brynley,

           

          I had a similar issue the other day where the globals wouldn't stick. I solved the issue by adding a commit record script step after the global was set.

           

          As for the length of your script, pass the layout name into the script as a parameter. That way your basic script becomes

           

          Go to layout [(get(scriptparameter)]

          set field [ gLayoutChoose ;  get(scriptparameter)]

          Commit records/Requests

           

          without all the else ifs.

           

          Hope that helps.

           

          Mike

          • 2. Re: Popup Menu to change layouts/Script Triggers?
            chris.schmitz

            A couple of questions.

            - Does this solution not allow for the status toolbar? A popup menu that changes to a layout sounds like the layout popup menu built into the status toolbar. You might be able to save yourself some pain and scripting if you just control the layouts that the user can switch to by managing layouts and controlling what shows in the list and what does not and grouping the layouts into folders.

            - What version of FM are you using? If you're using FM version 10 or newer you can leverage the OnObjectModify script trigger. Create a value list of the layout names you want the user to be able to navigate to, attach that list to your popup menu field, create a script that has the step "Go to Layout [by calculation]" where the calculation is your popup menu field, attach that script to the popup menu field using an OnObjectModify script trigger. If you do this the user will navigate to the layout as soon as they choose the layout name from the popup menu. The only down side to this is the value list of layout names has to match your layout names exactly. If they're off by even a space or a carriage return it will not resolve. This also means that if you ever change a layout name you have to make sure it matches in the value list.

             

            All in all, if you can use the built in layout navigation popup menu I'd say go for that. Why build a tool over again?

            • 3. Re: Popup Menu to change layouts/Script Triggers?
              MikeMcErlean

              I should have taken more time to read the questions.

               

              If your pop up list is on field gLayoutChoose,

               

              The triggered script becomes

              Commit record/Request (to get the value to stick)

              if [ . . . make sure gLayoutChoose is part of the value list you display . . . )

              Go to layout [gLayoutChoose]

              Else

              . . . add feedback to the user telling they why their change didn't work . . .

              End if

               

               

              Mike

              • 4. Re: Popup Menu to change layouts/Script Triggers?
                brynley

                Hi Chris and Mike

                 

                I am electing to hide the Status toolbar because scripting out Delete etc can not be easily scripted around - am using FM11 Adv.

                 

                Normally I would just use buttons but this solution needs quite a few buttons and it gets a bit messy (once you put lots of buttons you tend to start think of splitting them into "logical groups"...)

                 

                Plus I need to not show some buttons to all users - so I have a "user/group" thing that defines what things they can see via gLayoutChoose - so it does tick most of the boxes...

                 

                I am using "onObject Modify" which does work - attached as a Trigger.

                 

                The Commit after each if-else seems to work - so I'll see how it goes now.

                 

                Thanks for your comments/help!

                 

                Brynley