Newbies Hanz57 0 Posted November 25, 2020 Newbies Share Posted November 25, 2020 I am trying to omit the duplicate email address but keep the last and latest one on my foundset. What I have tried: After getting my foundset, I sort by email address and then by Creation Time Stamp. Then I tried to loop through each record and compare the Email field with the next record Email Field using GoNthRecord but it is not working. Gurus out there, please help. My Code Sort Records [Restore; With dialog: Off] // sort email then by CreationTime Go to Record/Request/Page[First] Set Variable[$i;Value:1] Loop if [T02d_actcrm_EMAIL||id_contact||preferred||::Email_Address = GetNthRecord(T02d_actcrm_EMAIL||id_contact||preferred||::Email_Address; $i+1) Omit record else Set Variable[$i; Value:$i+1] Go to Record/Request/Page[Nesxt;Exit after last: On] end if End Loop Link to post Share on other sites
comment 1,800 Posted November 26, 2020 Share Posted November 26, 2020 (edited) I believe it should be sufficient to do: # SORT BY CATEGORY Sort Records [ Restore; No dialog ] Go to Record/Request/Page [ First ] Loop Exit Loop If [ Get ( RecordNumber ) = Get ( FoundCount ) ] If [ YourTable::Category = GetNthRecord ( YourTable::Category ; Get ( RecordNumber ) + 1 ) ] Omit Record Else Go to Record/Request/Page [ Next ] End If End Loop However there is a faster way: define a summary field sCount that counts some field in your table that cannot be empty. Then make the script do: # SORT BY CATEGORY Sort Records [ Restore; No dialog ] Go to Record/Request/Page [ First ] Loop Exit Loop If [ Get ( RecordNumber ) = Get ( FoundCount ) ] Omit Multiple Records [ GetSummary ( YourTable::sCount ; YourTable::Category ) - 1 ] Go to Record/Request/Page [ Next ] End Loop Edited November 26, 2020 by comment Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now