Krokocil
Krokocil

Reputation: 1

If Else Velocity Script Not Working Weird Problem

need your input on this. i'm creating a logic for an email using velocityscript

#set($test = "{{lead.test_change}}") (value is only "Up" or "Down")
$test

what happen is it will render "Down"

but if i put

#set($test = "{{lead.test_change}}")
#if($test == "Down")
  it works
#else
  not working
#end

it renders "not working"

it seems like it didn't catch the conditional if. whereas it should match "Down"

Upvotes: 0

Views: 64

Answers (1)

Casey Grimes
Casey Grimes

Reputation: 127

These sorts of things can be hard to diagnose without more context, so I'd recommend the following:

  1. Try to print {{lead.test_change}} as plain text and see if it actually renders anything. A common error that can occur is not checking off the field so Velocity will reference it, so this can narrow down these sorts of issues.
  2. When you're sending an email to test, double-check that you have set an example record for the email to check against; otherwise, the Velocity will render without specific field references.
  3. You may need to normalize what text comes back to, especially if there are capitalization issues. Velocity is quite literal and will reject "down" if you are looking for "Down".

Upvotes: 0

Related Questions