Skip to main content
Known Participant
January 29, 2013
Question

list find?

  • January 29, 2013
  • 2 replies
  • 595 views

I have a form with mutiple text fields for user to enter email addresses.  I don't want them to enter the duplicate emails so created two lists here


Existing_EmailList: list all emails in the table.


Current_EmailList: all from the form (included from table and new email just enter)


I've tried to do ListContains, and Listfind but none of them work.  Can you help?

<cfset Existing_EmailList = valuelist(getCurrentEmail.email, ',') />
test@test.com, yes@yes.com, no@no.com

<cfset Current_EmailList = arguments.email />
test@test.com, yes@yes.com, no@no.com,no@no.com,one@one.com


<!---<cfif ListContains(Existing_EmailList, #Current_EmailList#)>--->
<cfif Listfind(Existing_EmailList, #Current_EmailList#)>
<cfset duplicate = true>
<cfelse>
<cfset duplicate = false>
</cfif>

Thanks

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
January 29, 2013

How come the longer list is coming in as an argument? What is the point of one list completely including the other? Why not just find out whether the new e-mails are in the database as Dan suggests? It seems odd to be comparing two lists.

Inspiring
January 29, 2013

I suggest a different approach altogether.  Query the database for the email submitted to see if it already exists.