2 Replies Latest reply on Aug 6, 2015 6:50 AM by Stu412

    Multiple user defined find script

    Stu412

      Title

      Multiple user defined find script

      Post

      I have a script which I use to find and omit certain records in an On Layout Entry scenario and I wish to add to this so that a user can select the dates of the records to be returned.  I'm using global fields for the date selection and passing these through to the script find routine.

      The problem I'm having is that if I search for all records with :

      31/01/2014 

      31/01/2013

      31/01/2011 (Two thousand and eleven)

      The routine, despite showing only three dates in debug, pulls through records for 2012 as well, which I don't want.

      The script part is pretty simple and consists of two parts.  First part removes anything I don't want, the second part is to show the years I do want to see from what's remaining:

      #Part 1

      Enter Find Mode

      New Record Request

      Set Field (DataTable::Filter; "XXX") //Remove any records marked as "XXX"

      Omit Record

      Perform Find

      #Part 2

      Enter Find Mode

      New record/request

      Set field (DataTable::CustomerID; $CustomerID_FK)

      Set field (DateTable::Date;$FirstGlobalDate)

      New record/request

      Set field (DataTable::CustomerID; $CustomerID_FK_)

      Set field (DataTable::Date;$SecondGlobalDate)

      .

      etc for three more repetitions per global field

      Constrain found set

      Hope that's ok for people, I don't understand why it's ignoring the fact I don't want it to find 2012.

      Thanks

      Edit

      Have just discovered that if any of the global date fields are empty, FM will return all years' data.

      Anybody know of a simple way to disallow the find on a year if it's empty as that should solve this problem?

      Thanks

        • 1. Re: Multiple user defined find script
          philmodjunk

          Note: there are no global fields in your script. You are using variables. They work just fine for what you are doing but they aren't fields and they aren't global.

          You can enclose each section of your script inside an If block that keeps that code from executing if your variable is empty.

          If [ Not IsEmpty ($SecondGlobalDate) ]
             New record/request
             Set field (DataTable::CustomerID; $CustomerID_FK_)
             Set field (DataTable::Date;$SecondGlobalDate)
          End If

          • 2. Re: Multiple user defined find script
            Stu412

            (Big) slip of the keyboard - glad we both knew what I meant!

            Thanks for the help there, works like a charm