4 Replies Latest reply on Apr 12, 2015 8:36 AM by tays01s

    Finding an email



      Finding an email


      I have a script, part of which is shown below, to put a new email into the Users::Email field and perform a find to see if it's already listed. I try to Find the complete field, since it is an email, but despite this, it's still failing to perform a find:

      Freeze Window

      Perform Script [ “Allow user abort” ]

      Go to Layout [ “Users” (Users) ]

      Set Variable [ $EmailFind; Value:Users::Email_find ]

      Enter Find Mode [ ]

      Set Field [ Users::Email; $EmailFind ]

      Perform Find [ Specified Find Requests: Find Records; Criteria: Users::Email: “==” ] [ Restore ]

      If [ IsEmpty (Users::Email) ]
      New Record/Request

        • 1. Re: Finding an email

          In your Perform Find, I would remove the criteria.  You seem to enter find mode, set the field for what you're looking for and should just perform a find. 

          Its hard to follow the logic of this partial script.  I guess the If statement/step is so if you don't find the email create a new record?  I would think you should use Get(lasterror)=401 // no records match find request, or Get(lasterror) <>0.  I would also set error capture to "on"

          • 2. Re: Finding an email

            OK, got rid of the criteria and yes, if there are no records found the script goes on to create a new record.

            Running the Debugger it shows that no records are found for a sample email for which there is definitely a record; in fact I have that record open on the layout while performing the find and the email/record disappear when I get to 'perform find'. However, I'm not clear on what to do about this.

            • 3. Re: Finding an email

              The @ symbol is a find operator. If you want to specify the @ operator as actual find criteria and not that operator, the text with that character needs to be enclosed in quotes.

              Both of the following examples achieve that end:

              Set Field [Users::email ; "==" & Quote ( $Email ) ]
              Set Field [Users::email ; "==\"" & $Email &"\"" ]

              • 4. Re: Finding an email

                Great the: "==" & Quote ($EmailFind), did the trick.

                I'll start to chew on the next error!