I have 3 data extensions and in 2 of them the syntax of First Name is the same and in the third the syntax is different. I am trying to write a script to pull the First name. The amp script is working; the only issue I am facing is when the same email address with the same key is in 2 data extensions; although its deduped at the time of the send the first name appears twice. I can't figure what exactly is missing in the if logic to prevent this. I know I can use a query activity to format the name for the third DE to match the other 2 and use the %%%% for pulling the first name but I need to understand why my current script isnt working.
Any idea is appreciated! thanks, G
%%[
var @rows2,@row2,@rowCount2
Var @lookupValue2
SET @lookupValue2=AttributeValue('Contact ID')
SET @rows2=LookupRows('FirstNamesDEs','Contact ID',@lookupValue2)
SET @rowCount2=rowcount(@rows2)
If @rowCount2>0 then
Var @first2
SET @row2=row(@rows2,1)
SET @first2=field(@row2,'First Name')
]%%
%%[else]%%
%%[endif]%%
%%[
var @rows3,@row3,@rowCount3
Var @lookupValue3
SET @lookupValue3=AttributeValue('Contact ID')
SET @rows3=LookupRows('FirstNamesDe2','Contact ID',@lookupValue3)
SET @rowCount3=rowcount(@rows3)
If @rowCount3>0 then
Var @first3
SET @row3=row(@rows3,1)
SET @first3=field(@row3,'First_Name')
]%%
%%[else]%%
%%[endif]%%
%%[
var @rows4,@row4,@rowCount4
Var @lookupValue4
SET @lookupValue4=AttributeValue('Contact ID')
SET @rows4=LookupRows('FirstNames_Exclusions','Contact ID',@lookupValue4)
SET @rowCount4=rowcount(@rows4)
If @rowCount4>0 then
Var @first4
SET @row4=row(@rows4,1)
SET @first4=field(@row4,'First_Name')
]%%
%%[else]%%
%%[endif]%%
%%[if @first2==@first3==@first4 then]%%
%%=v(@first2)=%%
%%[endif]%%
%%[else]%%
%%[if @first2==@first3 then]%%
%%=v(@first2)=%%
%%[else]%%
%%[endif]%%
%%[if @first2==@first4 then]%%
%%=v(@first2)=%%
%%[else]%%
%%[endif]%%
%%[if @first3==@first4 then]%%
%%=v(@first3)=%%
%%[else]%%
%%[endif]%%
%%[if not empty (@first2) OR not empty (@first3) or not empty (@first4) then]%%
%%=v(@first2)=%%%%=v(@first3)=%%%%=v(@first4)=%%
%%[else]%%
%%[
var @text
set @text="Dear Traveler"
Output(v(@text))
]%%
%%[endif]%%