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"
]%%
0

2 Answers 2

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

2
  • 1
    Plus defining a variable helps with handling empty or null values, reducing syntax errors. Commented Jul 20, 2017 at 23:22
  • True will update answer
    – 0xsegfault
    Commented Jul 20, 2017 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .