1 Reply Latest reply on Oct 7, 2014 10:43 AM by philmodjunk

    Help with simple find script



      Help with simple find script


      I'm trying to write a find script that loops through all database records and finds records that have the matching ID. When I get to the Perform Find script step it always ends up not finding any matching records, even though I've verified that that there are matching records for the data by performing manual finds using the same information. I'm assuming that I'm doing something incorrect with the Perform Find script step.

      Set Error Capture [ On ]
      #Opens the First Address Book record and gets the UIDSet Field [ Main::gCurrentRecord; PCAB_OpenFirstRecord ] Loop
      #Test to make it is a good recordExit Loop If [ LeftWords(Main::gCurrentRecord; 1) = "!!ERROR" or LeftWords(Main::gCurrentRecord ; 1) = "END" ]
      #Not sure if I need this but am making a variable that that matches the search criteria in case I need to use that instead of a
      field data.Set Variable [ $contactABID; Value:Main::gCurrentRecord ] Show All Records
      Go to Layout [ “Find Matching ABID” (Contacts) ] EnterFindMode[ ]
      [ Pause ]
      Perform Find [ Specified Find Requests: Find Records; Criteria: Contacts::Address Book ID: “= $ContactABID” ]
      [ Restore ]
      If [ Get(FoundCount) = 0 ]
         #Will Perform some actions here   Show Custom Dialog [ Message: "No Matching Record"; 
         Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
      End IfSet Variable [ $counter; Value:$counter +1 ]
      #Opens the next record in Address Book and gets the UIDSet Field [ Main::gCurrentRecord; PCAB_OpenNextRecord ]
      End Loop


      Thanks in advance for any help. :)

        • 1. Re: Help with simple find script

          When a scripted find fails, there are two simple debugging tricks that might reveal a clue:

          Temporarily remove the set error capture step so you can see the precise error message being returned.

          Immediately after performing the script, select "modify last find" and inspect the find criteria used by the script to perform the find. You can even try modifying the criteria to see if you can figure out what change is needed.

          I prefer to use a different approach to scripting a find as shown in these examples: Scripted Find Examples

          But I'd try using a find criteria of just $ContactABID (no enclosing quotes, no = operator) and see if that works.

          Also, the Perform Find script is overwriting any criteria you enter while the script is paused in Find Mode.