4 Replies Latest reply on Dec 15, 2010 9:37 AM by JohnWolcott

    Constrain Found Set script step fails

    JohnWolcott

      Title

      Constrain Found Set script step fails

      Post

      I have a simple table with Date, Date_Type, and Type fields.  (Actually there are a few more, like a primary key, a secondary key, a date created field and a date modified field, etc. lest you think I am a complete beginner.)  Date is a date field, the other 2 are text fields.  Date_Type has values "Projected" "Appointment" and "Actual".  Type has vaules "Phone" " Test" "Skin Check" and "Chart Review".  There are 3 buttons on the layout.  One button finds all records with Date_Type = "Projected" and omits those with Type = "Chart Review".  The other two buttons find either just the Type = "Phone" or Type = "Test" and Date_Type = projected.

      I thought I could do this with one script using script parameters.  The button to find all types except "Chart Review" passes no script parameter.  The other two buttons pass either "Phone" or "Test".  The script below works for the first button, finding all records except "Chart Review" types.  But it fails when used for the other 2 buttons.  Instead, it finds all records.  If I omit the Constrain Found Set step, then the same script works for the other two buttons.  It seems that if there are no records to constrain (omit) the script finds all 4 types with Date_Type = "Projected".  It isn't a big deal having 2 scripts doing 3 things, but I think I could have 1 script do all 3 things.

      In a previous post, PhilModJunk showed a user how to add a new request to omit certain records and stated that it could be used in a script, but I don't know how to add a new request in a script except with the Constrain/Expand Found Set steps.

      Enter Find Mode []

      SetField [Dates:Date_Type; "Projected']

      SetField [Dates:Type; Get ( ScriptParameter )

      Constrain Found Set [Restore]

      Perform Find []

       

      The Criteria in the "Specify Find Request" part of the Constrain Found Set step has

      Find Records     Dates::Date_Type: [Projected]

      Omit Records    Dates:Type: [Chart Review]

        • 1. Re: Constrain Found Set script step fails
          philmodjunk

          Note the script step: New Record / Request

          In find mode, this step creates a new request.

          Constrain Found Set seems like an odd option here. Wouldn't Perform Find [Restore] make more sense? I've found out the hard way, that an Omit request doesn't really play nice with Constrain.

          • 2. Re: Constrain Found Set script step fails
            JohnWolcott

            I tried adding that step originally, and then adding the SetField step, but I couldn't figure out how to get it to omit the records.  I was expecting to have some options when I added the New Record/Request step, such as "Find/Omit" and the search criteria, but I didn't see any options.  Obviously I am missing something here.  So what do I do after I add the New Record/Request step?

            • 3. Re: Constrain Found Set script step fails
              philmodjunk

              In find mode, omit record functions as though you clicked the Omit button for a manual find. That's a bit funky but it works. After specifying all your other criteria that you want your records to match, add new / record request, use set field to set the values you want omitted then add Omit record before finishing up with Perform Find[].

              • 4. Re: Constrain Found Set script step fails
                JohnWolcott

                Thanks so much!  And thanks for the explanation about omitting records in a scripted find.  So my script now looks like this and works for all 3 buttons.

                Enter Find Mode []

                SetField [Dates::Date_Type; "Projected']

                SetField [Dates::Type; Get ( ScriptParameter )

                New Record/Request

                SetField [Dates::Type; "Chart Review"]

                Omit Record

                Perform Find []