0

I have a paid program that I'm trying to promote and I'm trying to send a block of content within an email only to the customers who don't have it active. I wrote this if statement but I'm getting an error and I don't know why?

%%[

        set @WSubscriptionProgram = Lookup("Subscribed Customers","IsActive","CustomerID", @CustomerID)
        set @SubscriptionData = Lookup("Subscribed Customers","CustomerID","CustomerID", @CustomerID)

        if ((@SubscriptionData == @CustomerID) AND (@WSubscriptionProgram == 'False')) OR NOT EMPTY(@SubscriptionData)) then

        ]%%

        %%[ /* Menu */ ]%% %%=ContentBlockByID("8605")=%%

        %%[

        else 

        /* Do Not Show Any Content */

        endif

]%%
  • 1
    Which is the error you are getting? – fromero Jan 10 at 9:59
7

There are a few things that I see here:

  1. You don't declare where @CustomerID comes from
  2. I don't understand why you would check this condition, as this will always be true since it comes from the lookup used: @SubscriptionData == @CustomerID - or did I misunderstand?
  3. Is @WSubscriptionProgram a mandatory field? If yes, then it will never be empty and the second condition will also always resolve to true

Try something like this instead:

%%[
set @CustomerID = _subscriberkey
set @WSubscriptionProgram = Lookup("Subscribed Customers","IsActive","CustomerID", @CustomerID)
set @SubscriptionData = Lookup("Subscribed Customers","CustomerID","CustomerID", @CustomerID)

if @WSubscriptionProgram == 'False' OR NOT EMPTY(@SubscriptionData) then

]%% 

%%=ContentBlockByID("8605")=%%

%%[endif]%%

To make above more lean, you could use LookupRows() if you're fetching all the data from the same DE.

Additionally, you're saying:

I'm trying to send an email only to the customers who don't have it active.

Including AMPscript in the email won't prevent it from being sent to everyone - it will just display content based on the conditions that are defined. If you actually only need to send it to people who don't have a subscription, then just filter the list you're using.

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.