1 Reply Latest reply on May 3, 2011 2:42 PM by philmodjunk

    marking instances of matching records

    ThomasWaldron

      Title

      marking instances of matching records

      Post

      i'm trying to tweak this script to work. 

      The idea is that as a user is inputting data on a new record, I have a script that will tell them if the person they are entering has any previous records (not uncommon, and we need to keep all of them). The script searches for a matching previous one (indicated with an "X" in the "Mark" field), then performs a find that pulls up the new record and any matching and returns the user to the new record to finish entering data, but allowing them to see matching entries in the found set. I have everything working except... 

      I want it to make an "X" in the Mark field if there are other records for that person, and keep it blank if there are not other records. For the sorting process I have the script mark a "D" in the mark field while searching so as to separate it from all other members that have multiple records, and after the search is complete replace it with an "X" for multiple records and "" for single records. Script pasted below. 

      ("dummybox" is a hidden, multi-purpose temporary use box for scripts such as this)

      Perform script [“script that goes through entire database and marks matching records with a D”]

      Perform find (all records with D)

      Sort by date

      Go to first

      Loop:

      Replace field contents [Mark; “X”]

      Replace field contents [dummybox; serial numbers]

      Go to next, exit after last

      End loop

      Replace field contents [Mark; If (dummybox=”1”; “”; “X”) ]

      And then i clear the dummybox for future use. 

      The problem is this also clears the "X" from the earliest instance of a matching record, but I only want it to clear the "X" if there are NO matching records! 

      I'm sure there's better ways to do this. Suggestions?

        • 1. Re: marking instances of matching records
          philmodjunk

          Replace field contents updates the specified field of all records in a found set. Unless you pull up different found sets each time around within the loop, you would not place these steps inside a loop as they are doing exactly the same thing to all the records each time you loop.

          If you want to modify just the current record, use set field instead.

          By using a self join relationship, you can indicate that duplicates exist for a given record and you can use a portal to display them in a list on your layout--all without any scripting required in many cases.