0
%%[ 
        set @travelinterest= RequestParameter("tli")

        set @travelinterest1= RequestParameter("tli1")

        set @travelinterest2= RequestParameter("tli2")

        set @travelinterest3= RequestParameter("tli3")

        set @travelinterest4= RequestParameter("tli4")

        set @travelinterest5= RequestParameter("tli5")

        set @travelinterest6= RequestParameter("tli6")

        set @travelinterest7= RequestParameter("tli7")

        set @travelinterest8= RequestParameter("tli8")

        set @travelinterest9= RequestParameter("tli9")

        set @travelinterest10= RequestParameter("tli10")

        set @travelinterest11= RequestParameter("tli11")

        set @travelinterest12= RequestParameter("tli12")

        set @favouritebcdestination = RequestParameter("bcd")

        set @email = "testingprupose1@gmail.com" 


    UpdateDE("B2CSubscribe_AN",1,"Email",@email,"Travelinterest", Concat(@travelinterest,";",@travelinterest1,";",@travelinterest2,";", @travelinterest3,";",@travelinterest4,";",@travelinterest5),"Favouritebcdestination",Replace(@favouritebcdestination,",",";"))
    ]%%

In form page i have to concetanate all the travel interest values which does not have empty value , if one travel interest value is empty,then i want to skip and update the remaining twelve values, if three travel interest values are empty update the remaining 10 values using concat function i have tried , but logic is not coming anyone please help with code, if i want to check all conditions, i used to 10 updateDE function? guide me with sample code?

someone suggests me :
Why not just do a javascript if(this.checked) function to fill in a hidden input field when each box is checked. This would remove any need to concat or do anything server-side as it would already be in a single field

How to use javascript ? for this scenario help me

2

I wouldn't use JavaScript, you can easily achieve this with AMPscript. This code should do the trick:

%%[ 
var @travelinterest, @travelinterest1, @travelinterest2, @travelinterest3
var @travelinterest4, @travelinterest5, @travelinterest6, @travelinterest7
var @travelinterest8, @travelinterest9, @travelinterest10, @travelinterest11
var @travelinterest12, @favouritebcdestination
var @email, @interestsTemp, @interests

set @travelinterest= RequestParameter("tli")
set @travelinterest1= RequestParameter("tli1")
set @travelinterest2= RequestParameter("tli2")
set @travelinterest3= RequestParameter("tli3")
set @travelinterest4= RequestParameter("tli4")
set @travelinterest5= RequestParameter("tli5")
set @travelinterest6= RequestParameter("tli6")
set @travelinterest7= RequestParameter("tli7")
set @travelinterest8= RequestParameter("tli8")
set @travelinterest9= RequestParameter("tli9")
set @travelinterest10= RequestParameter("tli10")
set @travelinterest11= RequestParameter("tli11")
set @travelinterest12= RequestParameter("tli12")
set @favouritebcdestination = RequestParameter("bcd")
set @email = "testingprupose1@gmail.com" 

set @interestsTemp = concat(
    iif(empty(@travelinterest),'',concat(@travelinterest,';')),
    iif(empty(@travelinterest1),'',concat(@travelinterest1,';')),
    iif(empty(@travelinterest2),'',concat(@travelinterest2,';')),
    iif(empty(@travelinterest3),'',concat(@travelinterest3,';')),
    iif(empty(@travelinterest4),'',concat(@travelinterest4,';')),
    iif(empty(@travelinterest5),'',concat(@travelinterest5,';')),
    iif(empty(@travelinterest6),'',concat(@travelinterest6,';')),
    iif(empty(@travelinterest7),'',concat(@travelinterest7,';')),
    iif(empty(@travelinterest8),'',concat(@travelinterest8,';')),
    iif(empty(@travelinterest9),'',concat(@travelinterest9,';')),
    iif(empty(@travelinterest10),'',concat(@travelinterest10,';')),
    iif(empty(@travelinterest11),'',concat(@travelinterest11,';')),
    iif(empty(@travelinterest12),'',concat(@travelinterest12,';'))
    )

/*remove trailing semicolon*/
set @interests = substring(@interestsTemp,1,subtract(length(@interestsTemp),1))

UpdateDE("B2CSubscribe_AN",1,
        "Email",@email,
        "Travelinterest",@interests,
        "Favouritebcdestination",Replace(@favouritebcdestination,",",";"))
]%%
|improve this answer|||||
  • last occuring semicolon @Eliot Harper – SFDC Jun 29 '17 at 7:04
  • @SFDC, I deliberately omitted that as I assume that they don't want to include a semicolon delimiter after the last value. e.g, my code will return France;Germany;Spain not France;Germany;Spain;. – Eliot Harper Jun 29 '17 at 7:06
  • your code is working only for last value if i check, if i check intermediate value and i am not checking last value , then semicolon occuring – SFDC Jun 29 '17 at 7:10
  • @EliotHarper I have one doubt in Regex- i have tried %%[ outputLine(concat("<h4>Replace parenthetical text with space</h4>")) set @s = "whee (whatever it is) whoop;" set @p = "\;\";" set @m = RegExMatch(@s, @p, 0 , "IgnoreCase") set @o = replace(@s,@m, " ") outputLine(concat("input: ",@s,"<br>")) outputLine(concat('pattern: "',@p,'"<br>')) outputLine(concat("match: ",@m,"<br>")) outputLine(concat("replaced: ",@o,"<br>")) The output is = v(@o) ]%%, i want to replace semicolon with comma from above sentence, what pattern i have to give? please help me – testing ela Jul 3 '17 at 8:32
  • I have little confusion in regex , can you please help – SFDC Jul 3 '17 at 8:34

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.