10 Replies Latest reply on Jul 29, 2013 3:32 PM by phanh

    Detect user selection and perform find

    phanh

      We have a volunteer database that allows the secretaries to find volunteers based on the selected activity. The script sends them to a new layout where they select the activity (such as Fundraising.) This script works... in previous version. Here is the script:

      Screen Shot 2013-07-25 at 3.21.49 PM.png

       

      Since then, we move to the separation model and the script doesn't give us the expected result. It displays all the volunteers without the filters (building and activity). Do we have to capture the user selection as a temporally variable? Then use that to filter out the data? How do we capture the user input to a checkbox?

       

      Screen Shot 2013-07-25 at 3.29.09 PM.png

       

      Thank you in advance for the advice.

        • 1. Re: Detect user selection and perform find
          BruceRobertson

          I see that your script is using the Perform Find [ Restore ] script step.

           

          Geneally I advise to NEVER use that option.

          I suggest that you use a method I call explicit scripted finds.

          It goes like this:

           

          Enter find mode

          Set field [ someField; someValue ]

          Perform Find

           

          The advantage of this method is that you can immediately see what the script is doing just by looking at the script.

           

          Since you are using a checkbox field, then it is important to recognize that a checkbox field is just a text field, and what it really contains is the checked values separated by returns.

          So if the user had checked Health Fair and Registration and PTA, then the contents of the field are as follows:

           

          Health Fair

          Registration

          PTA

           

          However, the order of the items isn't necessarily the same as the value list, so the contents might actually be:

           

          PTA

          Registration

          Health Fair

           

          Your find script will need to enter find mode; loop through the checked items, creating a new request for each item, then perform the find.

          • 2. Re: Detect user selection and perform find
            BruceRobertson

            Like this ( see attachment )

            • 3. Re: Detect user selection and perform find
              debi

              phanh,

               

              Check the first layout in your script. It does not seem to be based on any TO. Also, the two layouts will need to be based on the same TO for a simple layout-switch to present users with the found set; otherwise you will need a GTRR (go to related record) script step or the like.

               

              Does that help?

               

              Debi Rubel
              FullCity Consulting

              • 4. Re: Detect user selection and perform find
                taylorsharpe

                Here, here, Bruce.  I fully concur with not using the "Perform Find [RESTORE]" because you can't tell by looking at the script what it is doing.  I'm at a bit of a loss to analyze this script without being given a copy of it because I can't look in the Perform Find steps to see what is being searched on. 

                 

                I'm quite confident you are searching for things in a related table and the search hasn't taken into account the type of relationship (one-to-one, one-to-many) and what happens if there is no related record in a relationship. 

                 

                If you'll rewrite the script like Bruce suggests and then give us a snap shot of the relationship graph, I'm sure we'll figure it out for you. 

                • 5. Re: Detect user selection and perform find
                  phanh

                  Thank you, Bruce! The example does exactly what I look for. Unfortunately, the search condition doesn't pass to the Perform Find function. Hopefully, I can explain this in more details.

                   

                  Each school has a value list for activities. All volunteer have a text field for the selected activity for each school. The relationship between the tables are: volunteer_data table contains all the information related to the volunteer (including the vol_interest_AMS_activities text field), volunteer_data_inout table contains the login and logout time, AMSactivities_data table is similar to your meeting table

                  Screen Shot 2013-07-29 at 9.48.06 AM.png

                   

                  Here is the screenshot as we running through the script:

                  Screen Shot 2013-07-29 at 9.49.00 AM.png

                  It seems like nothing was passed into the Perform Find() function because the script returns all volunteers as the result (error 103: missing relationship). How do we watch the value of the Perform Find() function?

                  Screen Shot 2013-07-29 at 9.50.00 AM.png

                  Any further advice is really appreciated.

                  • 6. Re: Detect user selection and perform find
                    BruceRobertson

                    Why is there a go to related record statement? It doesn't belong there.

                    • 7. Re: Detect user selection and perform find
                      BruceRobertson

                      Also: when debugging the script, stop on the peform find command. You will still be in Find Mode.

                      Then the screen should show you what values it has placed in the fields in find mode.

                      • 8. Re: Detect user selection and perform find
                        phanh

                        We tested around and forgot to comment out the code. It is now

                        • 9. Re: Detect user selection and perform find
                          BruceRobertson

                          Therefore it is now working correctly?

                          • 10. Re: Detect user selection and perform find
                            phanh

                            Remove that and also correct the Set Field code right above it. We compared the wrong variables. It is working now!

                            Thank you very much, Bruce!!!