0

Sometimes I forget to list the variables names in the AMPscript block and they still work just fine. Can I go and not list any of them? Is there anything that can go wrong if I don't list any?

I just wanna make sure I'm not missing something here. Thanks.

e.g.

%%[
Var @variable1, @variable2
Set @variable1 = "something"
Set @variable2 = "something else"
]%%

vs.

%%[
Set @variable1 = "something"
Set @variable2 = "something else"
]%%
3

It's a hit and miss. In might work in this situation but imagine having a 200 line Ampscript block and trying to debug it? You don't want to complicate things by having to check for this too.

Best practice is to declare them.

UPDATE:

As Gortington pointed out, defining a variable helps with handling empty or null values, reducing syntax errors

  • 1
    Plus defining a variable helps with handling empty or null values, reducing syntax errors. – Gortonington Jul 20 '17 at 23:22
  • True will update answer – Samuel Dare Jul 20 '17 at 23:33
0

I find not declaring is reliable when working with simple IF statements and marketing content otherwise, I agree with above, though, consistency is required as best practive.

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.