1

Ideal state, show a calculation of field "@ytd_savings_per_participant" divided by 3 as %%=v(@Lattes)=%% within a dynamic message. The message is based as well on the field "@ytd_savings_per_participant". If the value is under 300 in "@ytd_savings_per_participant" I'd like it to say

"That could buy %%=v(@Lattes)=%% number of Lattes"

I cannot get the variable to populate here. I can get it to pull in outside of the dynamic field but now within. Code below as well as screenshot attached to show the two places I put the %%=v(@Lattes)=%% field.Screen shot of preview and test

var @YTDS, @message, @ytd_savings_per_participant, @num2, @Lattes

Set @ytd_savings_per_participant = ytd_savings_per_participant

Set @YTDS = FormatNumber(@ytd_savings_per_participant, "C")

Set @num2 = 3
Set @Lattes = Divide(@ytd_savings_per_participant, @num2)

]%%

%%[if @ytd_savings_per_participant <=299 then
  set @message = "With those savings you could buy %%=v(@Lattes)=%% latt&eacute;s"


elseif @ytd_savings_per_participant >=300 AND @ytd_savings_per_participant <=1000 THEN
 set @message = "With those savings you could buy a new flatscreen"

elseif @ytd_savings_per_participant >=1000 AND @ytd_savings_per_participant <=1999 then
 set @message = "With those savings you could buy a new sofa"
 
 elseif @ytd_savings_per_participant >=2000 AND @ytd_savings_per_participant <=3000 then
  set @message = "With those savings you could buy a family vacation"

ENDIF
]%%
<center>
 <br>
  &nbsp;<div align="center">
  <span style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #FFFFFF; font-size: 20px; line-height: 23px;">Dollars Saved Lattes:%%=v(@Lattes)=%%</span> </div><br>
  <table align="center" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td style="background: #ffffff; color: #17A062; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; line-height: 28px; padding: 15px 25px 15px 25px;">%%=v(@YTDS)=%%
        
        
      </td>
    </tr>
  </table>
    <div align="center">

    <span style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #FFFFFF; font-size: 20px; line-height: 23px;">
    <br>%%=v(@message)=%%&sup1;
    </span>
    <br><br>
  <span style="font-family: Tahoma,Geneva,sans-serif; color: #FFFFFF; font-size: 14px; line-height: 16px;">
    Get an estimate of your other savings<br> with our calculator.
</span>
    <br><br>
  
      
    </div>
  
</center>

In the above code you can see I put the value %%v(@Lattes)=%% in 2 places to test if it would work. It only pulls in when outside of the variable message

3
  • 1
    try to concat this: set @ message = concat("With those savings you could buy ", @ Lattes , " latt&eacute;s") – EazyE Dec 23 '20 at 5:19
  • Thanks @EazyE that worked!! – Tiffany Moon Dec 23 '20 at 15:30
  • I moved my comment to answer, go ahead and mark it as the answer – EazyE Dec 23 '20 at 17:27
2

From comment:

You should use concact on this line

set @message = "With those savings you could buy %%=v(@Lattes)=%% latt&eacute;s"

to

set @message = concat("With those savings you could buy ", @Lattes , " latt&eacute;s")

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.