7 Replies Latest reply on Oct 26, 2010 11:04 AM by philmodjunk

    scripts help with constain found set



      scripts help with constain found set


      I am writing a script that I want to find all records within a date (this is working find) and then I want to constrain the found set by the following

      Find records

      evaluators_decision = "goal met" (it works fine at this point)

      but I also need to to do the following

      evaluators_decision = "gf"

      evaluators_decision = "nga"

      I tried to write Evaluators_decision = "goal met" AND "gf" AND "nga" but that didn't work.

      Any sugestions thanks

        • 1. Re: scripts help with constain found set

          What data to you actually have in evaluators_decision? Is this a check box field where more than one value can be selected or do you want all records where this field contains "gf" or "nga"?

          • 2. Re: scripts help with constain found set

            Its a drop down with 5 items in it and I only want all records that have "gf" "nga" "goal met"

            • 3. Re: scripts help with constain found set

              You don't actually need Constrain Found Set for this, but since you've got that part working, you can do this:

              Enter Find Mode[]
              Set Field [evaluators_decision ; "goal met"]
              New Record/Request
              Set Field [evaluators_decision ; "gf"]
              New Record/Request
              evaluators_decision ; "nga"]
              Set Error Capture [on]
              Constrain Found Set[]

              This searches your found set for any records where Evaluators_Decision = "goal met" or "gf" or "nga".

              Let me know if you want to see how to do this in a single find.

              A sneaky alternative to the above script that may or may not work for you (and I think the above approach is safer):  If goal met, gf and nga are the only values in your field that containe the letter g, you could use this single criteria to find all three: *g*.

              • 4. Re: scripts help with constain found set

                Yes, please show me how to do this in a single find. Also what if I wanted to incorporate another field like; contract_type = "dbe" AND udbe?

                Thanks the info is a great help to me.

                • 5. Re: scripts help with constain found set

                  You've indicated that you are finding records that fall on a specified date (possibly a range of dates).

                  If that date is entered by the user in a global date field. gContract Date, before they perform this script,

                  Enter Find Mode []
                  Set Field[YourTable::ContractDate ; YourTable::gDateField] //gDateField must have global storage specified for this to work
                  Set Field [YourTable::evaluators_decision ; "goal met"]
                  Duplicate Record/Request
                  Set Field [YourTable::evaluators_decision ; "gf"]
                  Duplicate Record/Request
                  Set Field [YourTable::evaluators_decision ; "nga"]
                  Set Error Capture [on]
                  Perform Find[]

                  Duplicate record request avoids having to re-enter the date with each new request.

                  To also specify records where contract_type = "dbe" OR "udbe"

                  You add another set field step and then generate 5 more requests so that each request specifies a different combination of criteria for Evaluators_decision and contract_type. (3 criteria for one field x 2 criteria for 2nd field = 6 different combinations of criteria).

                  Given that complexity, it may be simpler to set up the find in stages with Constrain Found Set as you originally invisioned this or you might be able to add one more line to the above script: Set Field [YourTable::contract_Type ; "*dbe"] if dbe and udbe are the only values in the field that end in the letters "dbe".

                  • 6. Re: scripts help with constain found set

                    a little confused on how you said to add the contract_type "udbe" and "dbe" and "ngr" into the script.

                    Appreciate you help I tried but something not getting the bulb in my head to fire.


                    • 7. Re: scripts help with constain found set

                      I actually gave you more than one option depending on the possible data in the value list for contract_type. If they have a subscript in common, you can use the * operator and simplify your script. Your last post added one more value, ngr, which doesn't have any text in common so that option won't work and checking for 3 possible values instead of 2 makes for 9 requests instead of 6.

                      I'm going to back up here, and suggest you use constrain found set in 2 or more stages for this. That will greatly simplify your script and be easier to understand as well. Just keep in mind that when you create multiple requests like this, you are telling FileMaker "find records that match the criteria in the first request or the criteria in the 2nd or the criteria in the 3rd ..."