0

I have 3 Data Extensions:

  • one used as target which is the audience to contact
  • one which stores products and email addresses. Here the email addresses match the ones present in the previous DE
  • one containing products of fallbacks, used in case the email address of the DE target is not in the second DE

I would like to retrieve in the same ampscript info stored in the second and third DE. The logic behind is: if the email address of target DE is in the second DE, then retrieve the products in the second DE, otherwise retrieve the products in the third DE (where there is no match of email addresses)

The ampscript below only retrieve products from DE_2 where I have the list of products per email addresses.

%%[
VAR @email, @rows, @rowCount, @counter, @row, @productdescription
SET @email = [email]
SET @rows = LookupRows("DE_2", "email", @email)
SET @rowCount = RowCount(@rows)
IF @rowCount > 0 THEN
FOR @counter = 1 TO @rowCount Do 
SET @row = Row(@rows,@counter)
SET @@productdescription = Field(@row,"@productdescription")
]%%

%%=v(@@productdescription)=%% 

%%[
next @counter
ENDIF
]%%
17
  • What have you tried, and where are you stuck? Please share the ampscript you have written so far. May 18 at 7:17
  • @LukasLunow added in the comment. Thanks
    – Gio
    May 18 at 7:32
  • Please go through your questions, and mark answers as accepted. May 18 at 7:42
  • @LukasLunow thank you but it is not working. should I change "retreive"?
    – Gio
    May 18 at 7:47
  • Did you add this additional column to your faalback DE? May 18 at 7:48

1 Answer 1

1

You simply need to have a fallback scenario in your script, which is triggered in case no matching records are found in your vol_Newsletter data extension.

Keep in mind, that LookupRows function always needs a parameter to filter by. Hence you should add a column, like retrieve, where a fixed value is present in all the rows of your fallback data extension - so they will be matched:

%%[
VAR @email, @rows, @rowCount, @counter, @row, @productdescription
SET @email = [email]
SET @rows = LookupRows("vol_Newsletter", "email", @email)
SET @rowCount = RowCount(@rows)
IF @rowCount == 0 THEN
SET @rows = LookupRows("fallbackDE", "retrieve", "1")
SET @rowCount = RowCount(@rows)
ENDIF
FOR @counter = 1 TO @rowCount Do 
SET @row = Row(@rows,@counter)
SET @productdescription = Field(@row,"productdescription")
]%%

%%=v(@productdescription)=%% 

%%[
next @counter
]%%

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