0

Mergefield into a Mergefield essentially

I have a segment/list as a DE - Columns (email | brand | lang )

I have a 2nd DE - Columns - ( lang | image )

my image uses mergefields from the 1st DE/Segment/List to form a URL

example image - http:/www.test.com/%%brand%%%%lang%%.jpg

I have a lookup that brings the image column in. This works but it does not merge in brand and language to form the url. Is it possible to make this work?

1
  • Please post the code for your lookup(). Aug 30, 2016 at 10:41

1 Answer 1

0

Your "mergefields" or personalization strings can only be referenced with the double-percent notation if they are columns in your sending Data Extension or are Profile Attributes. Any value retrieved outside of those two things needs to be referenced using the v() AMPScript function. For example:

%%[
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i

set @lookupValue = "whee"
set @numRowsToReturn = 0 /* 0 means all */
set @rows = LookupOrderedRows("DataExtensionName",@numRowsToReturn,"DEColumn1 desc, DEColumn2 asc","LookupColumn", @lookupValue)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

for @i = 1 to @rowCount do

var @DEColumn1, @DEColumn2
set @row = row(@rows,@i) /*get row based on loop counter */
set @DEColumn1 = field(@row,"DEColumn1")
set @DEColumn2 = field(@row,"DEColumn2")

]%%

Row %%=v(@i)=%%, DEColumn1 is %%=v(@DEColumn1)=%%, DEColumn2 is %%=v(@DEColumn2)=%%

%%[

next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

I'd also recommend using the concat() function to build your URLs:

%%[
var @URL, @brand, @lang
set @lang = AttributeValue("Language")
set @brand = AttributeValue("brandcode")
set @URL= concat("http://",@brand,"xxxxx.com/?ul=", @lang)

]%%

<a href="%%=redirectto(@URL)=%%" alias="test URL"/>link text</a>

Reference:

AMPScript Lookup Examples

8
  • so i'm working on this again and have hit a dead end.
    – lyslexic
    Oct 6, 2016 at 12:14
  • so i'm working on this again and have hit a dead end. I have this %%[ Set [AT]SubLang = Language Set[AT]SubBC = BRANDCODE and in my DE row I have this http://%%=v([AT]SubBC)=%%xxxxx.com/?ul=%%=v([AT]SubLang)=%%". The problem is that it seems to replace my personalization fields and then bring in the value from the DE
    – lyslexic
    Oct 6, 2016 at 12:19
  • I've updated the second example in my answer. Give something like that a try. Oct 6, 2016 at 13:16
  • it works but when i put this in my DE and use a lookup to pull it, i get nothing.
    – lyslexic
    Oct 6, 2016 at 14:10
  • DE Column = html (<a href="%%=redirectto(@URL)=%%" alias="test URL"/>link text</a>)
    – lyslexic
    Oct 6, 2016 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .