0

I am trying to replicate my email on a Cloud Page as I would like to have the Chinese version of it on a landing page - so people who speak Chinese can click on the lang version from the email. Note the email contains some AMPscript variables. The dynamic code displays the subscribers' form selections as they are subscribing to events. Is it possible to do something like this? See my code here:

%%[ 
var @Variable1,@Variable2,@Variable3,@Variable4,@Variable5,@Variable6,@sk 
Set @sk = AttributeValue("_subscriberkey") 
Set @Variable1 = Lookup("ent.SF_Forms","Custom_Field_1","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
Set @Variable2 = Lookup("ent.SF_Forms","Custom_Field_2","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
Set @Variable3 = Lookup("ent.SF_Forms","Custom_Field_3","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
Set @Variable4 = Lookup("ent.SF_Forms","Custom_Field_4","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
Set @Variable5 = Lookup("ent.SF_Forms","Custom_Field_5","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
Set @Variable6 = Lookup("ent.SF_Forms","Custom_Field_6","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_members_00898") 
]%% 
%%[ 
var @Variable7,@Variable8,@Variable9,@sk 
Set @sk = AttributeValue("_subscriberkey") 
Set @Variable7 = Lookup("ent.SF_Forms","Custom_Field_1","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_nonmembers_00899") 
Set @Variable8 = Lookup("ent.SF_Forms","Custom_Field_2","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_nonmembers_00899") 
Set @Variable9 = Lookup("ent.SF_Forms","Custom_Field_3","SFMC_ID",@sk,"Form Name","mtl_mserv_2018-05-10_mwcs18_nonmembers_00899") 
]%%
  • For a start, I'd be using LookupRows to retrieve a rowset rather than Lookup, as this is an unnecessary performance overhead (to make 9 separate lookup calls). Are you able to provide further information in what you are trying to achieve here? You mentioned that you are "replicate my email on a Cloud Page" — it seems to me that you shouldn't be building this a separate CloudPage, but just conditionally changing content when a user clicks on the 'view as web page ' link. – Eliot Harper Jun 23 '18 at 19:19
  • Hi - thanks for your reply. Since we are not 100% trusting the country to determine if a person speaks EN or Chinese, we are using the approach of adding a link to a chinese version on the EN email. This would open up a landing page replicating the email in Chinese lang. Reg the code, apologies as I have forgot including the rest, see below – Livia Trabucchi Jun 25 '18 at 9:39
  • %%[if @Variable1 == "true" THEN]%% 13:00-14:30 Drop-in Afternoon Tea Session %%[ENDIF]%% – Livia Trabucchi Jun 25 '18 at 9:50
  • and so on for each variable :) – Livia Trabucchi Jun 25 '18 at 9:50
  • This is a confirmation email for events they selected on a form previously. I would like this email to have the selected fields from the reg form automatically pulled in when sending it - which is working fine with this code. Since I want the Chinese version as well, I was trying to replicate that same process on the cloudpage and mirror the code there, but it doesn't seem working so far! really aappreciate some help, I ssaw that to achieve that I d need to add some code in there – Livia Trabucchi Jun 25 '18 at 9:53
1

As Eliot mentioned, it'd be better to do a LookupRows() function. This will allow you to validate the values coming from your email.

Be sure and use the CloudPagesURL() function when linking to the page, so that your AttributeValue() will return the Subscriber Key properly.

%%[

var @rows, @row, @rowCount, @sk, @i

set @sk = AttributeValue("_subscriberkey") 
set @formName = "mtl_mserv_2018-05-10_mwcs18_nonmembers_00899"
set @rows = LookupRows("ent.SF_Forms","SFMC_ID", @sk, "Form Name", @formName)
set @rowCount = rowcount(@rows)

output(concat("sk: ", @sk))
output(concat("<br>formName: ", @formName))

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @variable1
    var @variable2
    var @variable3
    var @variable4
    var @variable5
    var @variable6
    var @variable7
    var @variable8            
    var @variable9

    set @row = row(@rows, @i) /* get row based on counter */
    set @variable1 = field(@row,"Custom_Field_1")
    set @variable2 = field(@row,"Custom_Field_2")
    set @variable3 = field(@row,"Custom_Field_3")
    set @variable4 = field(@row,"Custom_Field_4")
    set @variable5 = field(@row,"Custom_Field_5")
    set @variable6 = field(@row,"Custom_Field_6")
    set @variable7 = field(@row,"Custom_Field_7")
    set @variable8 = field(@row,"Custom_Field_8")            
    set @variable9 = field(@row,"Custom_Field_9")            

    ]%%

    <br>variable1: %%=v(@variable1)=%%
    <br>variable2: %%=v(@variable2)=%%
    <br>variable3: %%=v(@variable3)=%%
    <br>variable4: %%=v(@variable4)=%%
    <br>variable5: %%=v(@variable5)=%%
    <br>variable6: %%=v(@variable6)=%%
    <br>variable7: %%=v(@variable7)=%%
    <br>variable8: %%=v(@variable8)=%%
    <br>variable9: %%=v(@variable9)=%%

    %%[

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

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.