3 Replies Latest reply on Oct 30, 2010 10:19 PM by ZhizhongNeo

    Using checkbox values to search on another text field using scripting.

    ZhizhongNeo

      Title

      Using checkbox values to search on another text field using scripting.

      Post

      Hi, thank you in advance for any help.

      My issues is this:

      I have 1 checkbox field that contains values  from a "Topics" table. Using a script, i have to paste all the checkbox values in a field, in another table layout to search for all topics, is there a way i can do that?

        • 1. Re: Using checkbox values to search on another text field using scripting.
          philmodjunk

          Set Variable [$TopicsList ; Value: YourTable::YourTopicsCheckBoxField ]
          Go To Layout [//select other layout]
          Enter Find Mode []

          At this point, the details of the script will vary depending on the type of search you want to perform. Let's say you have two values selectd in the topics checkbox field, "History" and "Current Events". You could search your other table for all records where the topics field stores History AND Current Events or you can search for all records where the topics field stores History OR Current Events.

          If you want the AND version, you need just one set field instruction: Set Field [Your2ndTable::YourTopicsField ; $TopicsList ].

          For the OR version, you'll need a loop so that your script can create a separate find request for each topic in $TopicsList.

          Set Variable [$I ; Value: 1 ]
          Loop
              Set Field [Your2ndTable::YourTopicsField ; GetValue ( $TopicsList ; $I )]
              Exit Loop If [ $I = ValueCount ( $TopicsList ) ]
              Set Variable [$I ; Value: $I + 1]
              New Record/Request
          End Loop

          With either option, you use the following script steps to finish up:

          Set Error Capture [on] //keeps the "No Records Match..." dialog from interrupting the script if no records were found
          Perform Find []

          At this point you can add steps to sort the records and do anything else you need. You can also check to see if any records were found and display a custom dialog telling the user that none were found if you want.

          • 2. Re: Using checkbox values to search on another text field using scripting.
            FentonJones

            It is not clear what you want to do, "all values must match" or "any values match".  If "all" values must match, you could just put them into a script Variable (via the Set Variable step). Then go to the other table, go into Find mode, and set the regular field to the $variable (whatever name you gave it).

            This is an AND Find. It will only Find records which have ALL of the values.

            A more precise way to search for exact matches, but for ANY value, is to set the values into a global field, then use a relationship (or self-relationship) from the global to the other checkbox field. "Find" using Go To Related Record. (Or just relate the 2 checkbox fields.)

            If you require a precise match for all values, with no possible overlap, then more is needed. One method would be a script with a Loop, to pull the values out of the checkbox one at a time. Find for 1st one, then use Constrain Find for subsequent values. If it ever gets an error, then you know it's no-go.