0

I have the following AMPScript:

%%[
var @Custom_2, @variable

set @Custom_2 = Custom_2

if Not Empty(@Custom_2) then
     set @variable = concat(" ",@Custom_2)
elseif Empty(@Custom_2) then
    set @variable = ""
endif
]%%

And am printing the results in an email with:

%%=v(@variable)=%%

Custom_2 is a nullable text field. When previewing a record with an empty Custom_2, the word 'FALSE' is printed when the expected value is nothing should be printed.

Using this AMPscript below resolves the issue, as does renaming the Custom_2 field to anything else, but I don't understand why.

 if Not Empty(@Custom_2) AND Not(@Custom_2 == "False") then 
   set @variable = concat(" ",@Custom_2)
 endif

Both Custom_1 and Custom_2 share the same field properties. I've tried deleting the field from the data extension then re-adding it, only to encounter the same issue.

Is there documentation that explains why this would be occurring?

1
  • 1
    Please update your question to include the code that's setting the @Custom_2 variable -- prior to your conditional. Feb 23, 2021 at 2:46

1 Answer 1

1

Do you by chance have a Profile Attribute named Custom_2? That could be the source of the False value. Profile Attribute values will take precedent over data extension field values.

In general, I would not recommend referencing send context variables without checking to see if they exist or not -- using AttribueValue().

I'd add some debugging output before and after your conditional.

I'd also simplify your conditional. Doesn't appear that the elseif is needed -- or the any else for that matter.

%%[
var @Custom_2, @variable

set @debug = 1
set @Custom_2 = AttributeValue("Custom_2")

if @debug == 1 then
  output(concat("<br>custom_2: |", @custom_2,"|"))
endif

set @variable = ""

if Not Empty(@Custom_2) then
     set @variable = concat(" ",@Custom_2)
endif

if @debug == 1 then
  output(concat("<br>variable: |", @variable,"|"))
endif

]%%

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.