2 Replies Latest reply on Apr 23, 2015 3:27 PM by MikeCrumley

    Scripting A Complex Find

    MikeCrumley

      Title

      Scripting A Complex Find

      Post

      Hi there,

      I am trying to generate a script that goes to a different layout and enters criteria from two different value lists in another layout. I know this might sound weird, but this is what I have tried:

       

      Set Variable [ $Name; Value:Time::AR Name ]

      Set Variable [ $Date; Value:Time::AR Date ]

      Go To Layout [ "AbsenceReport" (AbsenceReport) ]

      Enter Find Mode []

      Set Field [ AbsenceReport::Name ID; $Name ]

      Set Field [ AbsenceReport::First Date Absent; $Date ]

      Perform Find []

       

      Time::AR Name and Time::AR Date are both value lists, and I'd like the search criteria to be from the "Current Record" or "Last Viewed Record" in the Time layout. Is this even possible?

      I'm an intermediate user, so I know that I'm definitely getting something wrong here. I've been toiling over this for the past couple of days, and I can't seem to figure it out. Any help is greatly appreciated! Thanks in advance!

        • 1. Re: Scripting A Complex Find
          philmodjunk

          The basic script looks correct, but I wonder about names and name IDs. Is it possible that AR Name is a text field with the student's name and Name ID is a field (possibly number) with the student's ID number? That would cause this script to fail.

          In fact, just having AR Name text and Name ID number--even if both store a name would cause your script to fail. So would having AR Name text and Name ID number.

          Another source of trouble is the layout change. Changing layout's can trip a very long list of script triggers on both layouts. If one or more of those have been set up to perform a script, your current script is paused, the triggered script is performed--possibly changing context, values, layouts...before your paused script is allowed to continue. This can interfere with your expected results.

          • 2. Re: Scripting A Complex Find
            MikeCrumley

            Got it to finally work! Thank you for your help PhilModJunk! Here's the only line that I changed:

             

            Set Field [ AbsenceReport::Name; $Name ]

             

            Just took "ID" out of the string, effectively making it reference a different field, and it works like a charm. The "Name ID" field is a combination of a number and then a person's name. I can see how that would cause problems now, and I probably should have caught that.