Here's what I have to start with:


    VAR @facilityRow


Now I basically need to add in multiple "lookuprows" within the same template in order to pull their specific "Phone_blurb" and "transaction Type" by their language.

I have all separate data extensions created, each with their own language blurb and transaction type:


Now I just need to add all of them as AMPscript within the one template. I'm a beginner to AMPscript so I'm not sure how it works, but I'm trying to say "If, "then" statements here:



So on, and so forth.... just not sure how to write that in AMPscript all together. Any idea?

  • Is there a reason you have a separate data extension for each language phone blurb? – Adam Spriggs Sep 28 '16 at 0:22
  • Originally each language was its own separate email. My client had created each individual DE for all languages for each separate language email being deployed(manually). What I'm essentially doing is making it easier & creating 1 dynamic template. I just didn't know how to add in the AMPscript portion to fit into the 1 template. I could combine all DE's into one as you recommended. So once I create the 1 DE with all languages, I would take your setup below and place above my HTML within my template? Do I need to change anything with your AMPscript below? (Sorry, I'm still learning AMPscript) – Charlene Hixon Sep 28 '16 at 14:58
  • If you combine your DE into a single one as I suggested, then, yes, you can just drop this code at the top of your template or in an email content area. You may need to tweak the DE and column names. – Adam Spriggs Sep 28 '16 at 15:12
  • With your code below, I had created one DE and named it "phoneBlurb" , that way it should pickup the correct DE which is listed, correct? I also made sure that language and the transaction_type was in the sending DE which it is so we're good there. – Charlene Hixon Sep 30 '16 at 19:31
  • Also, if some of the languages don't have a blurb associated, so I'd want to make them blank and show no blurb of any sort, is that listed in this code or can you help me add the appropriate AMPscript to show that as well? OR will it just not show within the body since I won't include the ampscript tieback in those versions? – Charlene Hixon Sep 30 '16 at 19:41

I'd create a single Data Extension (PhoneBlurbs) containing the phone blurbs for all languages and then retrieve it like this:

%%[ /* Modify to view AMPScript <div style="display:none"> */

var @language, @transactionType, @phoneBlurbRows, @phoneBlurbRow, @phoneBlurb
set @language = AttributeValue("language") 
set @transactionType = AttributeValue("transaction_type") 

/* retrieve rows from Phone Blurbs by language and transaction_type */
set @phoneBlurbRows = LookupRows("PhoneBlurbs", "Language", @language, "transaction_type", @transactionType)

/* check to see if row is found */
if rowcount(@phoneBlurbRows) > 0 then

  /* retrieve value from row and field */
  set @phoneBlurbRow = row(@phoneBlurbRows, 1) /* get row #1 */
  set @phoneBlurb = field(@phoneBlurbRow ,"PhoneBlurb") /* DE Column Name */


  /* default value if row is not found */
  set @phoneBlurb = concat("phone blurb not found for ", @language, " and ", @transactionType)


/* </div> */    
<br>language: %%=v(@language)=%%
<br>transactionType : %%=v(@transactionType)=%%
<br>phoneBlurb: %%=v(@phoneBlurb)=%%

The language and transaction_type need to exist in a column in your sending Data Extension or as a Profile Attribute.

| improve this answer | |

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.