0

I'm very new to ampscript and am having an issue with a snippet of ampscript showing as blank. This is what I currently have:

SNIPPET 1:

%%[ set @firstName = Lookup('master','first_name','email',email) 
IF @firstName == "" 
THEN set @firstName = "Friend" 
ENDIF ]%% 
Hey %%=v(@firstName)=%%, if you love someone let 'em know!

SNIPPET 2 (showing as blank):

%%[ set @smilereferralurl = Lookup('master','smile_referral_url','email',email) 
IF @smilereferralurl == "" 
THEN set @smilereferral = "Create an account to get your code." 
ENDIF]%% 
%%=v(@smilereferralurl)=%%

SNIPPET 3:

Imagine your balance of
%%[ set @smilepointsbalance = Lookup('master','smile_points_balance','email',email) 
IF @smilepointsbalance == "" 
THEN set @smilepointsbalance = "0" ENDIF ]%%  
%%=v(@smilepointsbalance)=%% + 1000 more inkbucks

Snippet #2 is not showing anything but the other two are populating as expected. Any and all feedback is very much appreciated.

2

@smilereferral (sans "url" in the identifier name) is being assigned the value, but @smilereferralurl is what's being passed to the v() function. I.e., try:

set @smilereferralurl = "Create an account to get your code."
0

Firstly, I would recommend you to use Empty() to check if the string is empty, as it also checks whether it is null. E.g.

IF Empty(@smilereferralurl) THEN

Also, I don't see how your email string works, as the recipient email address normally is referenced emailaddr, as per this list of personalization strings. Other than that, your syntax looks correct. So my theory is that smile_referral_url is null in your case. EDIT: Mark G spotted the difference between the variable names referenced, where @smilereferral != @smilereferralurl

Also, if all three blocks are in the same email, you use three iterations through the same data extension. I will recommend using this approach, with a single iteration, using LookupRows:

%%[ 
set @recipientrows = LookupRows('master','email',emailaddr)
IF RowCount(@recipientrows) > 0 THEN
set @recipientdata = Row(@recipientrows,1) 
ENDIF
set @firstname = Field(@recipientdata, 'first_name')
set @smilereferralurl = Field(@recipientdata, 'smile_referral_url')
set @smilepointsbalance = Field(@recipientdata, 'smile_points_balance')

IF Empty(@firstname) 
THEN set @firstname = "Friend" 
ENDIF 
]%% 
Hey %%=v(@firstname)=%%, if you love someone let 'em know!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.