I am new to Salesforce and AMPscript and I am trying to set a condition to populate %%=v(@BodyContent)=%% with contact data (not journey data, therefore, I will need to use the Lookup) with a content block by id if the contact data attribute value returns true. If the value returns false or null I want to hide %%=v(@BodyContent)=%%.

  • here is what I have so far but it doesn't work:
    – Alex
    Aug 13, 2019 at 4:07

1 Answer 1


Welcome to SFSE. Lets get you hooked up with some good Ampscript reference links to start out with:

What you need is to use a lookup function as well as an IF statement, similar to as you described.

    /* Retrieve the identifier for your record in order to use in the lookup function */
    SET @id = AttributeValue('Id')

    /* Lookup the MyBooleanField field in your data extension. */
    SET @myField = Lookup('MyDataExtensionName','MyBooleanField','Id',@id)

    /* If the field is true then output the body content */
    IF @myField == 'True' THEN



You must log in to answer this question.

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