AnsweredAssumed Answered

Remove duplicate entries in the same field

Question asked by steveoh on Dec 28, 2015
Latest reply on Jan 12, 2016 by steveoh



So I'm working on a solution that sends out emails to selected contacts.  What I've created is a loop that copies selected records into a text field to then be put into an email recipient field when the email is sent.


My script is as follows:


Set Field [ Recipients::Global Counter ; "1" ]

Set Field [ Recipients::Recipient Emails ; "" ]


Go to Portal Row  [ Select ; First ]




If [ not IsEmpty ( Rec_Employees::Office Email ) ]

If [ PatternCount ( Rec_Employees::Office Email ; Recipients::Recipient Emails ) < 1]  // *note 1

Copy [ Select ; Rec_Employees::Office Email ]

Paste [ Recipients::Recipient Emails ]

Set Field [ Recipients::Recipient Emails ; Recipients::Recipient Emails & "," & "¶" ] // *note 2

End If

End If

Set Field [ Recipients::Global Counter ; Recipients::Global Counter + 1 ]

Go to Portal Row [ Select ; No Dialog ; Recipients::Global Counter ]

Exit Loop If [ Recipients::KeyCounter = Recipients::Global Counter ] // *note 3

End Loop


I believe the issue is as stated in note 1, but I am unsure how to fix the problem or the questions I should ask to find out why.  My hope is someone reading this will know a reasonably simple fix for this.


The duplicates are born as a result of more than one employee being from a particular office.  Each office has a generic email that the notice is sent to and so the list is born from the recipients' office email as opposed to their own.


Thanks in advance





*1 Intent here is to weed out the duplicates.  Did not work as intended.  I think this is where the fix needs to happen as it's searching only for the current line, which is empty prior to the text being inserted


*2 Values, as stated above, are stored on their own line for ease of use.


*3 Key Counter is a Calculation.  It's calculated with: Sum ( Rec_Employees::Selected ). The intention here is to give a total number of records so I would know when to stop the loop