1 2 Previous Next 21 Replies Latest reply on Jan 20, 2012 12:32 AM by NaturSalus

    Picker Issue

    NaturSalus

      Title

      Picker Issue

      Post

      Hello,

      I have a basic popup picker that does everything alright but consistently picking the selected value on the first try.

       

      Tables:

      Deviation

      Originator

      Person

        

      Table Occurrences (TOs):

      DEVIATION which is the TO of the Deviation table

      deviation_ORIGINATOR which is the TO of the Originator table

      deviation_originator_PERSON which is the TO of the Person table

       

      Relationships:

       DEVIATION --< deviation_ORIGINATOR >-- deviation_originator_PERSON

      DEVIATION::__kp_Deviation = deviation_ORIGINATOR::_kf_Deviation

      deviation_originator::_kf_Person = deviation_originator_PERSON::__kp_Person

       

      Layouts:

      Deviation_Detail layout based on the DEVIATION TO

      In the Body part of the Deviation_Detail layout there is the deviation_originator_PERSON::NameFirstLast field. On the upper right corner of this field there is a + button that triggers the Assign Person Originator Script

      deviation_originator_PERSON layout based on the deviation_originator_PERSON TO

      On the Header part there is a global field that triggers a Find script to search values in the deviation_originator_PERSON::NameFirstLast field

      On the Body part there is deviation_originator_PERSON::NameFirstLast field and to the right side there is the Choose button that triggers the Resum Script script step.

      On the Footer part there are the Cancel and New buttons.

       

       

      Scripts:

      Assign Person Originator

      Select Person Originator

       

       

      The  Assign Person Originator Script carries out two tasks:

      First, performs the Select Person Originator Script

      Second, gets the script result of the Select Person Originator Script, assigns it to the $PersonSelectedID local variable and finally sets the deviation_ORIGINATOR::_kf_Person =  $PersonSelectedID 

      Select Person Originator Script:

      # Error Handling
      Allow User Abort [ Off ]
      Set Error Capture [ On ]
      #
      Perform Script [ “Select Person Originator” ]
      #
      Set Variable [ $PersonSelectedID; Value:Get (ScriptResult) ]
      If [ not IsEmpty ( $PersonSelectedID ) ]
      // Refresh Window [ Flush cached join results; Flush cached external data ]
      Set Field [ deviation_ORIGINATOR::_kf_Person; $PersonSelectedID ]
      Commit Records/Requests [ No dialog ]
      End If
      Adjust Window [ Resize to Fit ]
      Exit Script [ ]

       

      I tried to add the Refresh Window script step to see if it fixed the issue, but it didn't

       

       The Select Person Originator Script  carries out the following tasks:

      First, opens the deviation_originator_PERSON layout as a popup window

      Second, pauses for the user to carry out desired actions.

      Third, assigns the deviation_originator_PERSON__kp_Person value to the $PersonSelectedID local value

      Select Person Originator Script:

      # Error Handling
      Set Error Capture [ On ]
      Allow User Abort [ Off ]
      #
      New Window [ Name: "Select"; Height: 80; Width: 80; Top: 50; Left: 100 ]
      Go to Layout [ “PersonPopUpSizer” (zRESOURCES) ]
      Show/Hide Status Area [ Hide ]
      Adjust Window [ Resize to Fit ]
      Go to Layout [ “Select Originator” (deviation_originator_PERSON) ]
      Sort Records [ Specified Sort Order: deviation_originator_PERSON::NameFirstLast; ascending ]
      [ Restore; No dialog ]
      Pause/Resume Script [ Indefinitely ]
      #User clicks Select, New or Cancel
      If [ Get ( ScriptResult) ≠ "Cancel" ]
      Set Variable [ $PersonSelectedID; Value:deviation_originator_PERSON::__kp_Person ]
      End If
      # User clicks "cancel"
      Close Window [ Current Window ]
      Exit Script [ Result: $PersonSelectedID ]

       

      THE ISSUE

      Everything runs fine but picking the selected value on the deviation_originator_PERSON layout and putting it back on the deviation_originator_PERSON::NameFirstLast field that is on the  Deviation_Detail layout.

      Sometimes it picks up the right value on the first try. Sometimes, it doesn't picks up the selected value.

      Most of the time it takes some seconds for the selected value to show on the deviation_originator_PERSON::NameFirstLast field.

      It never puts the wrong value on the deviation_originator_PERSON::NameFirstLast field. But sometimes you have to try two or three times till it does it right.

      In a word, my current setting looks at least unstable.

       

      Can you find out what is "wrong" with my current setting?

      Is there another alternative and more relaible way of getting the same results?

       

      Thanks,

       

      natursalus

        • 1. Re: Picker Issue
          philmodjunk

          Isn't the first script listed the "assign person originator" not "select person originator"? Makes no sense otherwise.

          How does "cancel" get set as a script result? What options have you specified for your cancel button in button setup? Is there a script for it?

          If you have FileMaker Advanced, enable the script debugger and run your script. It's the best way to see where/how the script goes awry. (Could be any number of layout based script triggers interferring with your script when you change layouts for all we can tell by looking at your scripts.)

          If you do not, I suggest getting a copy, it'll save you hours of frustration when a script doesn't do what you want. In the mean time, if you don't have advanced, you might add some show custom dialog steps and put variables, fields in the show custom dialog steps so you can tell which show dialog step was just executed and so you can inspect the values of key variables at that point in the script execution.

          • 2. Re: Picker Issue
            NaturSalus

            Hello Phil,

             

            Isn't the first script listed the "assign person originator" not "select person originator"? Makes no sense otherwise.

            Don't understand what you mean.

            The Select Person Originator is a subscript of the Assign Person Originator.

            The one that should take notice of the user selection on the deviation_originator_PERSON::NameFirstLast field is the Select Person Originator Script.


            I may understand that the naming convention looks elaborate, but in my project I have to derive from the Person table people that carry out different duties on the same layout and sometimes the same person carries out different duties. So imagine the number of TOs and naming convention to assure that FM doesn't gets crazy.

            Maybe someday, when in my eigthies I guess, the great minds behind FM development will understand the easy notion that you don't need to study a master to create databases. Just come up with user friendly tools that allow user create powerfull databases and let the programming do all the mathematically or logically correct settings.

             

            How does "cancel" get set as a script result? What options have you specified for your cancel button in button setup? Is there a script for it?

            When the user selects the Cancel button the Cancel Select Script is triggered. The Optional Script Parameter: "cancel"

            Cancel Select Script

            Exit Script [ Result: Case (Get (ScriptParameter) = "cancel" ; "Cancel" ; "") ]

             

            If you have FileMaker Advanced, enable the script debugger and run your script. It's the best way to see where/how the script goes awry

            I don't like script debugger. It seems you must study a master to figure out how it works.


            From your comments I derive that the Scripts are okay. Is this correct?


            Thanks,


            natursalus

            • 3. Re: Picker Issue
              philmodjunk

              Don't understand what you mean.

              Take another look at your first post. You have listed two different scripts with the same name: Select person originator. Since the first listed script calls a script named "select person originator" I must assume that the first listed script is named Assign person originator or it traps itself in an endless recursive loop.

              When the user selects the Cancel button the Cancel Select Script is triggered. The Optional Script Parameter: "cancel"

              Cancel Select Script

              Exit Script [ Result: Case (Get (ScriptParameter) = "cancel" ; "Cancel" ; "") ]

              What button options is epecified in button setup for this button? Halt, exit, resume, or pause?

              I don't like script debugger.

              I cannot recommend using the debugger too strongly. It's well worth the time and effort spent learning how to use it and it's not all that difficult to figure out. In your case, select the debugger from the tools menu, then start up your "assign" script. click the data viewer button (x=) to open a second window where you can watch the values of your variables and fields change as the scritp executes. Watch to make sure that your variables are getting the values you expect them to get.

              To step through the script in the debugger, methodically click the 2nd button from the top left to move through your script one step at a time. If a dialog or window pops up like this one will, click the appropriate button and go back to clicking that step into button to watch your scripts execute. To halt a script (You spotted the problem) click the button with the red X. If you close the debugger without clicking this button, the script will run from it's current point to the end automatically.

              Pay attention to any scripts that start up on their own without you clicking a button or the script calling it with a perform script step. These could be layout based script triggers and may be interfering with your scripts' correct function.

              From your comments I derive that the Scripts are okay. Is this correct?

              All I can say is that I don't SEE anything wrong with them, but I don't know all the details of your system design and that could be keeping me from spotting the issue here. (I could also just be temporarily blind. Wink)

              • 4. Re: Picker Issue
                NaturSalus

                Hello Phil,

                Take another look at your first post. You have listed two different scripts with the same name: Select person originator. Since the first listed script calls a script named "select person originator" I must assume that the first listed script is named Assign person originator or it traps itself in an endless recursive loop

                Okay my mistake.


                The  Assign Person Originator Script carries out two tasks:

                • First, performs the Select Person Originator Script
                • Second, gets the script result of the Select Person Originator Script, assigns it to the $PersonSelectedID local variable and finally sets thedeviation_ORIGINATOR::_kf_Person =  $PersonSelectedID 

                Assign Person  Originator Script:

                # Error Handling
                Allow User Abort [ Off ]
                Set Error Capture [ On ]
                #
                Perform Script [ “Select Person Originator” ]
                #
                Set Variable [ $PersonSelectedID; Value:Get (ScriptResult) ]
                If [ not IsEmpty ( $PersonSelectedID ) ]
                // Refresh Window [ Flush cached join results; Flush cached external data ]
                Set Field [ deviation_ORIGINATOR::_kf_Person; $PersonSelectedID ]
                Commit Records/Requests [ No dialog ]
                End If
                Adjust Window [ Resize to Fit ]
                Exit Script [ ]

                 

                What button options is epecified in button setup for this button? Halt, exit, resume, or pause?

                Current script: Resume


                Concerning the script debugger, since you took time to guide me, I'll do tomorrow morning. Now, it is 20:01 p.m. in Spain and I am a bit tired.

                Still, if you find something wrong with the Scripts, PLEASE LET ME KNOW.


                Hopefully, the debugger will point out something wrong.

                You have the patience of a Saint!

                Thanks one more time.

                I owe you tons of beers...

                natursalus

                • 5. Re: Picker Issue
                  NaturSalus

                  Hello Phil,

                  I run the Script Debbuger.

                   

                  The script behaves in a random manner:

                   

                  sometimes does what it is supposed to do: changes the deviation_ORIGINATOR::_kf_Person value to the value chosen by the user

                  sometimes keeps the original value for the deviation_ORIGINATOR::_kf_Person no matter what is the user choice.

                   

                  So I have decided to destroy my whole project and leave just the part that is causing the issue for you to have a look.

                   

                  I have uploaded the troubleshooting file here

                  To fire the scripts, simply press the + button.

                  Don't be misled if the first try works out. Just keep changing the person's name and you will see how on many occasions it doesn't do it right.

                  Hope you find some time slot in you busy agenda and have a look.

                  Thanks for your help.

                   

                  natursalus

                   

                  • 6. Re: Picker Issue
                    Sorbsbuster

                    I have to admit the scripting setup seems very complex if all you want to do is grab a name from a pop-up and populate a field.  But I'm sure you have your reasons.

                    I have clicked the blue + button and selected a person maybe 20 times corectly.  Then I eventually got a certain pattern of name choices not to wupdate.  I also noticed that if I clicked the 'New' button it was unclear to me how to add a name to the newly-created record, and then hitting 'Cancel' left me with a new, blank, record, so I think the interface needs a few tweaks.

                    I tried to debug it by creating 3 basic layouts, one for each table of Deviation, Originator, and Person and verifying that the data looked correct.  Because of the pattern of failure I suspected you may have erroneous duplicate values - but that didn't seem to be the case.  However, in checking your list of fields in the Person Table it has a  liberal spreading of <Table Missing> and <Field missing> warnings.

                    The field you have chosen to display on the Entry Layout is 'NameFirstLast' from the Person Table, and is defined as:

                    'Indexed from <Unknown> ; <Field Missing> & " " & <Field Missing>

                    So I suspect that is at least a contributor to the problem.  I would suggest you fix that first, then see if the problem goes away.

                     

                    • 7. Re: Picker Issue
                      NaturSalus

                      Hello Sorbsbuster,

                       

                      The field you have chosen to display on the Entry Layout is 'NameFirstLast' from the Person Table, and is defined as:

                      'Indexed from <Unknown> ; <Field Missing> & " " & <Field Missing>

                      So I suspect that is at least a contributor to the problem.  I would suggest you fix that first, then see if the problem goes away.

                      You are absolutelly right, I fixed it and uploaded the updated file.

                      Unfortunatelly, on the third try I run into the random pattern again. So, it must be something else.

                       

                      I have clicked the blue + button and selected a person maybe 20 times corectly.  Then I eventually got a certain pattern of name choices not to wupdate. 

                      Thank you for looking into my issue and for enduring it till being abel to reproduce the random pattern.

                       

                       

                      I also noticed that if I clicked the 'New' button it was unclear to me how to add a name to the newly-created record, and then hitting 'Cancel' left me with a new, blank, record, so I think the interface needs a few tweaks.

                      Right again, when I deconstrusted my project to create the troubleshoot_1 file I deleted a needed layout. Now it looks as it was supposed to look.

                      The idea is that if the user if the user doesn't find listed the person name that wants, he/she can enter People data directly from the Deviation_Detail layout without exiting the Deviation_Detail layout and jumping into the People_Detail layout.


                      This time I have reduced the degree of deconstruction so many nonexisting relationships will show up, ignore them.

                      I have uploaded the troubleshoot_1 file again.

                      Still the issue remains.

                       

                      Thanks,

                       

                      natursalus

                      • 8. Re: Picker Issue
                        Sorbsbuster

                        Why not:

                        - have a global field on the Entry Layout, with a Pop-up menu, from a value list of all the Person names
                        - let the user pick a name (really by selecting, behind the scenes, the PersonID)
                        - capture that PersonID as a $Variable
                        - freeze the window, navigate to whatever tables you want, create records if you want, and put the $PersonID wherever you want?

                        You wouldn't have to worry about controlling multiple windows (not easy), you wouldn't even have to worry about passing script results.

                        Have a separate button to allow users to add another name.

                        • 9. Re: Picker Issue
                          NaturSalus

                          Hello Sotbsbuster

                           

                          Why not have a global field on the Entry Layout, with a Pop-up menu, from a value list of all the Person names

                          The reason why I got into trouble is because when you have a lengthy value list a Popup Menu is not a valid option. This is why I have to set up a Pop Up Window and create a Picker System.

                          I hope that sometime in the future FM natively will convert a lengthy PopUp menu into a PopUp Window so that the user can esaily scroll down or search for the value he/she wants.

                          As  a matter of fact the deconstructed project seems to be failure proof and I have no clue about how to troubleshoot the whole project with dozens of layouts, tables and relationships...

                          Thanks,

                          natursalus

                          • 10. Re: Picker Issue
                            Sorbsbuster

                            "The reason why I got into trouble is because when you have a lengthy value list a Popup Menu is not a valid option."

                            Then  use a portal to the same listing, have a filter at teh top (like you currently have on your layout) and click a portal line to act the same way as a pop-up list would.

                            • 11. Re: Picker Issue
                              philmodjunk

                              You can also use a conditional value list in many cases to reduce the length of the value list displayed.

                              I've run this script till my fingers are tired and still get correct results each time. I put the kf field directly on the layout so that I could see if the script is correctly assigning the selected ID number--which it does each time. From what is described here, I suspect that the window fails to correctly refresh to display the name from the related record. It is the case that you see the previous name or an empty field when you select a person?

                              If so, this could be a platform specific issue as I've seen other cases where fields from related tables did not update the same way on each OS. I'm using windows XP. Any of you using a Mac?

                              It sounds a bit extreme, but if all else fails, try adding steps at the end of your script that switch in and out of Browse mode to see if that forces a more consistent screen refresh.

                              • 12. Re: Picker Issue
                                NaturSalus

                                Hello Phil,

                                It is the case that you see the previous name or an empty field when you select a person?

                                Correct

                                if there was no person on the target field I get an empty field after selecting a person

                                if there was a person on the target field I get the previous name after selecting the new person.


                                I've run this script till my fingers are tired and still get correct results each time. 

                                I believe you. 

                                The frustrating thing is that the troubleshooting_1 file no longer has the problem even though it derives from the whole project.

                                My reasoning is: if there is a problem with the scripting then the problem will show up both in the whole project and in the deconstructed file. But it doesn't.

                                I am running on a Windows 7 64 bits operating system.

                                I am so desperate that I am willing to let you have access to my whole project to see if you can find out the problem.

                                Since this is going to be a database for sale I can only grant you access through a private email of your choice.

                                Once the problem is sorted out no problem letting the FM community to know what was causing it and how it was fixed.

                                Thanks,

                                natursalus



                                • 13. Re: Picker Issue
                                  philmodjunk

                                  Before going that route, try re-indexing all the fields in your file. You can do this with the advanced recovery options and is the one exception I make to my personal rule of never using recovered files if there is any alternative to doing so.

                                  If you have FileMaker 11, you can use Advanced Recovery options to rebuild your file's indexes:

                                  1. With the file closed, select Recover from the File Menu.
                                  2. Select "Use advanced Options"
                                  3. Select only: "Copy File Blocks as-is" and "Rebuild Field Indexes Now".
                                  • 14. Re: Picker Issue
                                    NaturSalus

                                    Hello Phil,

                                    I recovered it but the same problem.

                                     

                                    natursalus

                                    1 2 Previous Next