13 Replies Latest reply on Feb 8, 2012 9:59 AM by NaturSalus

    Conditional Value List not Always an Alternative for a Long Value List

    NaturSalus

      Title

      Conditional Value List not Always an Alternative for a Long Value List

      Post

      Hello,

      In my project I have saeveral fields that are populated from value lists. The problem is that the value lists can get quite lengthy and in my case the Conditional Value List makes no sense.

      So the question is how to handle a lengthy value list when the Conditional Value List is not an option.

      Is there a way to "show" the value list values  inside a scrollable popup window?

      Thanks,

      natursalus

        • 1. Re: Conditional Value List not Always an Alternative for a Long Value List
          philmodjunk

          There are a number of methods--all requiring scripts, that I know of that can make long value lists easier to work with. And several could be popped up in a small floating window if you so desire.

          http://www.4shared.com/file/plr_jbkk/EnhancedValueSelection.html

          • 2. Re: Conditional Value List not Always an Alternative for a Long Value List
            NaturSalus

            Hello Phil,

            Thanks for the demo file. I'll study it.

             

            natursalus

            • 3. Re: Conditional Value List not Always an Alternative for a Long Value List
              NaturSalus

              Hello Phil,

              I got lost in your demo.

              My needs are much simpler.

              Two tables:

              Parent

              Child

               

              Parent table fields:

              __kp_Parent

              Parent Name

               

              Child table fields:

              __kp_Child

              _kf_Parent

              Child Name

              ParentName

               

              Table Occurrences:

              PARENT

              CHILD

               

              Relationship: PARENT::__kp_Parent = CHILD::_kf_Parent

               

              My purpose is adding to each Child record the ParentName of its related Parent record.

              The standard way of doing it is using either a Drop down list or a Pop Up menu with settings:

              Use values form first field: PARENT::__kp_Parent

              Also display values from second field: PARENT::ParentName

               

              However, the list of ParentNames is very large and cannot be reduced by a Conditional Value List. Therefore I need a way to show that lengthy list of ParentNames in a Portal on a popup window and from here select the ParentName that I want to relate to the current Child record.

              My first problem is that a Portal is used to show related records from, and without having established yet a relationship I want to show all the records of the Parent table on a portal on a pop up window. The solution that came to my mind is to create the AllPARENT table occurrence and establish the following cartesian relationship:

              PARENT::__kp_Parent X AllPARENT::__kp_Parent

               

              So far, I can run a script from a layout based on the Child table that pops up a window with a Portal showing all the values of the Parent table. From this pop up window I can select the desired Parent value and then transfer the AllPARENT::__kp_Parent value and use it to populate the CHILD::_kf_Parent.

              When the user is presented with the list of AllPARENT::__kp_Parent values in the Portal on the pop up window, he/she can select the desired value. When the user clicks into the AllPARENT::__kp_Parent field that contains the desired value, a script should be triggered (for example:  Add Selected Parent script):

              to capture the PARENT::__kp_Parent value for the selected record on the Portal

              and

              to transfer it into a variable (for example, $SelectedParentID).

               

              This I don't know how to do it. Hoe do I know which AllPARENT::__kp_Parent value was slected by the user? Could you help me on this part?

               

              Thanks,

               

              natursalus

               

               

              • 4. Re: Conditional Value List not Always an Alternative for a Long Value List
                philmodjunk

                The selection portals in the bottom of this demo layout are based on such an "all records" relationship as you describe. If you check out one of the portals in the demo while in layout mode, you'll find that they have been configured as buttons to run a script when the portal row is clicked to select a value. The only difference between the three portals is the method used to control what subset of all the portal items are visible--each has a different portal filter expression. I'd think you'd want to use one of these filtering methods as otherwise you have exchanged scrolling a very long drop down list of names for scrolling a portal with a very long list of names and that does not seem like much of an improvement. But the demo portals could be simplified down to what you describe.

                The button click in the portal makes that portal row the active row and then this script step:

                Set variable [$SelectedParentID ; AllPARENT::__kp_Parent]

                will copy the value of the portal record's ID into the variable, assuming your portal is to AllParent.

                If you have filemaker 11, you can double click a portal row and drill down into the actual script used with that button. You'll find a step very similar to the above used. It's more complex as it is adding a new child record with the selected value.

                • 5. Re: Conditional Value List not Always an Alternative for a Long Value List
                  NaturSalus

                  Hello Phil,

                  Thank you for your detailed explanation.

                  I'd think you'd want to use one of these filtering methods as otherwise you have exchanged scrolling a very long drop down list of names for scrolling a portal with a very long list of names and that does not seem like much of an improvement. But the demo portals could be simplified down to what you describe.

                  Certainly I will, buy frist I have to understand the rarionale behind the record selection part.

                  From the Child layout is triggered the Launch Parent Selection script that opens the pop up window that contains the Portal to AllPARENT TO and pauses for the user to make its selection of AllPARENT::__kp_Parent value. When the user makes his selection, the Select Parent script is triggered, gets the AllPARENT::__kp_Parent value selected by the user and pases it to the $SelectedParentID variable.

                   

                  Launch Parent Selection
                  # Error Handling
                  Allow User Abort [ Off ]
                  Set Error Capture [ On ]
                  #
                  Commit Records/Requests
                  #
                  # Add Manual Name
                  New Window [ Name: "Manual Selection"; Height: 400; Width: 600; Top: Get ( WindowTop ) + 132; Left: Get ( WindowLeft ) + 86 ]
                  Go to Layout [ “ParentSelection” (PARENT) ]
                  Show/Hide Status Area
                  [ Lock; Hide ]
                  Adjust Window
                  [ Resize to Fit ]
                  # script paused so that the user can make his selection
                  Pause/Resume Script [ Indefinitely ]
                  #Script Result from the Select Manual Script
                  Set Variable [ $ParentSelectedID; Value:Get (ScriptResult) ]
                  Go to Layout [ “CHILD” (CHILD) ]
                  Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]
                  Exit Script [ ]

                   

                  Select Parent
                  # Error Handling
                  Allow User Abort [ Off ]
                  Set Error Capture [ On ]
                  #
                  Set Variable [ $SelectedParentID; Value:AllPARENT::__kp_Parent ]
                  Exit Script [ Result: $SelectedParentID ]

                   

                  Still, I am doing something wrong because I am not getting the desired result. Certainly my scripts are wrong. But I don't see the mistake. Maybe you can have a look and spot my mistakes.

                  I have uploaded a demo file with the settings that I have used.

                   

                  http://www.4shared.com/file/dKiXa8BV/longvaluelist.html

                   

                  Thanks,

                   

                  natursalus

                  • 6. Re: Conditional Value List not Always an Alternative for a Long Value List
                    philmodjunk

                    Get script result will not return any value here as there is no perform script step used to call a script.

                    Make your button a resume script step

                    and use the set variable step I posted earlier instead of trying to extract the value from a script result.

                    You'll also need to close your pop up window at some point or at least use select window specifying the original window to hide it behind the original window.

                    • 7. Re: Conditional Value List not Always an Alternative for a Long Value List
                      NaturSalus

                       

                      Get script result will not return any value here as there is no perform script step used to call a script.


                      Launch Parent Selection
                      # Error Handling
                      Allow User Abort [ Off ]
                      Set Error Capture [ On ]
                      #
                      Commit Records/Requests
                      #
                      # Add Manual Name
                      New Window [ Name: "Manual Selection"; Height: 400; Width: 600; Top: Get ( WindowTop ) + 132; Left: Get ( WindowLeft ) + 86 ]
                      Go to Layout [ “ParentSelection” (PARENT) ]
                      Show/Hide Status Area
                      [ Lock; Hide ]
                      Adjust Window
                      [ Resize to Fit ]
                      # script paused so that the user can make his selection
                      Pause/Resume Script [ Indefinitely ]
                      #Script Result from the Select Parent Script
                      Close Window [ Current Window ]
                      // Set Variable [ $ParentSelectedID; Value:Get (ScriptResult) ]
                      Go to Layout [ “CHILD” (CHILD) ]
                      Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]
                      Exit Script [ ]

                       

                      You'll also need to close your pop up window at some point or at least use select window specifying the original window to hide it behind the original window.


                      Launch Parent Selection Script


                      # Error Handling
                      Allow User Abort [ Off ]
                      Set Error Capture [ On ]
                      #
                      Commit Records/Requests
                      #
                      # Add Manual Name
                      New Window [ Name: "Manual Selection"; Height: 400; Width: 600; Top: Get ( WindowTop ) + 132; Left: Get ( WindowLeft ) + 86 ]
                      Go to Layout [ “ParentSelection” (PARENT) ]
                      Show/Hide Status Area
                      [ Lock; Hide ]
                      Adjust Window
                      [ Resize to Fit ]
                      # script paused so that the user can make his selection
                      Pause/Resume Script [ Indefinitely ]
                      #Script Result from the Select Parent Script
                      Close Window [ Current Window ]
                      // Set Variable [ $ParentSelectedID; Value:Get (ScriptResult) ]
                      Go to Layout [ “CHILD” (CHILD) ]
                      Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]
                      Exit Script [ ]


                      Make your button a resume script step

                      I assume you mean the Continue button on the portal. This is the way it is on my demo file

                       

                      use the set variable step I posted earlier instead of trying to extract the value from a script result.


                      Select Parent Script


                      # Error Handling
                      Allow User Abort [ Off ]
                      Set Error Capture [ On ]
                      #
                      Set Variable [ $SelectedParentID; Value:AllPARENT::__kp_Parent ]

                       

                      Still not working, so I am missing something else.

                      • 8. Re: Conditional Value List not Always an Alternative for a Long Value List
                        philmodjunk

                        You left something out:

                        use the set variable step I posted earlier instead of trying to extract the value from a script result.

                        Set variable [$ParentSelectedID; AllPARENT::__kp_Parent]

                        Remove the resume button, you don't need it and it won't work.

                        Select the fields in your portal row that are set up as a button and open button setup.

                        In place of Perform script, select: Resume Script.

                        This way, clicking a row in the portal puts the focus on that portal row and then resumes your paused script so that the above set variable step can capture the primary key value of the current portal row in a variable.

                        There is a draw back to this method: Pressing the number pad Enter key will continue your paused script and this will be the same as selecting the first row of your portal. By using a $$GlobalVariable, we can eliminate this possibility and go back to having your portal row button perform a script, but let's get your current set up working first.

                        • 9. Re: Conditional Value List not Always an Alternative for a Long Value List
                          NaturSalus

                          Let's see...

                           

                          Select the fields in your portal row that are set up as a button and open button setup.

                          In place of Perform script, select: Resume Script.

                          Done

                          Remove the resume (Continue)  button, you don't need it and it won't work.

                          Certainly, now it makes no sense having it. Done


                          use the set variable step I posted earlier instead of trying to extract the value from a script result.

                          Set variable [$ParentSelectedID; AllPARENT::__kp_Parent]

                           This is the part that I wasn't getting right.

                          SO, first of all the Select Parent Script has been deleted since it doesn't make sense anymore.

                          Second, I have included the Set variable [$ParentSelectedID; AllPARENT::__kp_Parent] into the Launch Parent Selection Script that know is as follows:


                          Launch Parent Selection
                          # Error Handling
                          Allow User Abort [ Off ]
                          Set Error Capture [ On ]
                          #
                          Commit Records/Requests
                          #
                          # Add Manual Name
                          New Window [ Name: "Manual Selection"; Height: 400; Width: 600; Top: Get ( WindowTop ) + 132; Left: Get ( WindowLeft ) + 86 ]
                          Go to Layout [ “ParentSelection” (PARENT) ]
                          Show/Hide Status Area
                          [ Lock; Hide ]
                          Adjust Window
                          [ Resize to Fit ]
                          # script paused so that the user can make his selection
                          Pause/Resume Script [ Indefinitely ]
                          #Script Result from the Select Parent Script
                          Close Window [ Current Window ]
                          Set Variable [ $ParentSelectedID; Value:AllPARENT::__kp_Parent ]
                          Go to Layout [ “CHILD” (CHILD) ]
                          Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]
                          Exit Script [ ]

                           

                          I hope I have done my homework right.

                           

                          Still it doesn't put the selected value from the POrtal into the CHILD::_kf_Parent and CHILD::ParentName

                           

                          I have uploaded the modified version here:

                          http://www.4shared.com/file/_imIthiK/longvaluelist_2.html

                           

                          There is a draw back to this method: Pressing the number pad Enter key will continue your paused script and this will be the same as selecting the first row of your portal. By using a $$GlobalVariable, we can eliminate this possibility and go back to having your portal row button perform a script, but let's get your current set up working first.

                          Certainly I would like this problem to be addressed


                          • 10. Re: Conditional Value List not Always an Alternative for a Long Value List
                            philmodjunk

                            Put close window AFTER Set variable and it should work. You also do not need Exit script[] at the end of your script, but it does no harm to leave it there.

                            • 11. Re: Conditional Value List not Always an Alternative for a Long Value List
                              NaturSalus

                              Phil,

                              Alleluia!

                              I don't want to abuse you too much, at least today.

                              So concerning the:

                              There is a draw back to this method: Pressing the number pad Enter key will continue your paused script and this will be the same as selecting the first row of your portal. By using a $$GlobalVariable, we can eliminate this possibility and go back to having your portal row button perform a script, but let's get your current set up working first.

                              We can tackle it whenever you feel with stamina to do it.

                              Many thanks

                              natursalus


                               

                              • 12. Re: Conditional Value List not Always an Alternative for a Long Value List
                                philmodjunk

                                It's not that difficult to get to from what you have so far.

                                Go back to having your portal row button perform the script you had originally but with a few more steps added:

                                Set Variable [ $SelectedParentID; Value:AllPARENT::__kp_Parent ]
                                Go to Layout [ “CHILD” (CHILD) ]
                                Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]

                                Close Window [ Current Window ]

                                Halt Script

                                Now make a few small changes to your original script:

                                Loop
                                   Pause/Resume Script [ Indefinitely ]
                                   #Script Result from the Select Parent Script
                                   //
                                Set Variable [ $ParentSelectedID; Value:AllPARENT::__kp_Parent ]
                                End Loop
                                // Close Window [ Current Window ]
                                // Go to Layout [ “CHILD” (CHILD) ]
                                //Set Field [ CHILD::_kf_Parent; $ParentSelectedID ]

                                Note: It's best to temporarily remove or disable the "allow user abort" step while testing to make sure you don't get trapped in the infinite loop that now exists. (Halt script in the portal button script terminates the infinite loop for you.)

                                It's also often useful to add a "cancel" button to your pop up's layout that performs this script:

                                Close Window
                                Halt Script

                                That way your user can dismiss the pop up without making a selection. If you have fileMaker advanced you can even give the pop up's layout a custom menu that performs this script in place of the standard Close window menu option--which can enable the close button in the top right corner of your popped up window as well as the close window keyboard short cut.

                                • 13. Re: Conditional Value List not Always an Alternative for a Long Value List
                                  NaturSalus

                                  Hello Phil,

                                  I have implemented your suggestions without any problem.

                                  Nevertheless I have to pose you a pesky question. It was my understanding that all the improvements suggested in your latest post had the purpose of   preventing what you mentioned earlier:

                                  Pressing the number pad Enter key will continue your paused script and this will be the same as selecting the first row of your portal. By using a $$GlobalVariable, we can eliminate this possibility and go back to having your portal row button perform a script, but let's get your current set up working first

                                  However, when in the pop up window if I press the number pad Enter key I get the first row portal value put into the CHILD::ParentName field. 

                                  To me it is not a big deal but...

                                  Thanks,

                                  natursalus