0

On a CloudPages confirmation page I'm trying to write a code to lookup a value from the DE and based on their survey responses, output recommendations. For example, the DE could say 'SUV'. So on the confirmation page, I'd want to show text that said 'SUVs are XYZ'. Make sense?

I used the below code and tested it on an email and it worked. But of course it didn't work on the CloudPage and I don't know enough about the scripting language to manipulate my code. I've tried ClaimRow, LookupRowsCS etc etc. I just can't seem to pinpoint what ampscript I need to actually use.

Also, I don't have separate DEs created to house all the possible recommendations because I thought it would've been a lot easier to do If/Then statements.

%%[ var @car, @rows, @rowCount 

set @car = car 

set @rows = LookupRows("Name of DE","email", @email)  

  

    set @rowCount = rowcount(@rows)  

    if @car == "SUV" then   

        set @vehicle_message = "Text here on SUV" 
  

ELSEIF @car =="Convertible" then 

set @vehicle_message ="Insert text"



  ENDIF]%% 

<span style="font-family:Arial; font-size:14px; font-weight:bold"> 

  %%=v(@vehicle_message)=%%</span> 
0

I think it is necessary to bring the value of the email to be able to search for it in the DE, also add the name of the column where the type of vehicle is with the lookup formula

I would place the code as follows

 %%[ var @car, @email, @vehicle_message

set @email = RequestParameter("email") 

set @car = Lookup("Name of DE","Name of column from which to return a value","email", @email)  

  
if @car == "SUV" then   
set @vehicle_message = "Text here on SUV" 

ELSE @car =="Convertible" then 
set @vehicle_message ="Insert text"

ENDIF]%% 

<span style="font-family:Arial; font-size:14px; font-weight:bold"> 

%%=v(@vehicle_message)=%%</span>

I hope it helps you

1
  • That worked!! OMG!! That worked. I have been working on this for DAYS!!! And I swear at one point this was probably added to my code along with some gibberish. Thank you so very much @calu – SFMC for Dummies Apr 29 at 1:57

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.