0

I'm using an exclusion script that uses an HTML Content Block, is in the Content Block where all the ampscript logic lives, for the sake of simplicity, the ampscript in the Content Block only declares variables and returns the string 'excluded', in the Exclusion Script, the ampscript expression checks for this word. It all works fine when tested against Data Extensions with up to 2800 records, anything bigger than that just hangs and after 5-7 minutes, the send gets cancelled.

As a side note, before the January release, I could just check directly for the return variable in the Content Block, for example, %%=v(@result)=%%, but now, I've noticed that the result variable gets surrounded by HTML (table tag), so, I ended up checking for a specific word in the string returned from the Content Block.

Has anyone tried such scenario using an exclusion script after January release?

Content block:

%%[
    VAR @Debug, @SquadId, @job, @result, @MID, @subKey

    SET @Debug = 1
    SET @SquadId = 'DummyValue'
    SET @job = jobid
    SET @result = 'excluded'
    SET @MID = memberid

    SET @subKey = AttributeValue('_subscriberkey')

    IF @Debug == 1 THEN
        SET @result = 'excluded'
    ENDIF
]%%%%=v(@result)=%%

Exclusion script:

IndexOf(TreatAsContent(ContentBlockByID(12345)), "excluded") > 0
4
  • Can you update your question with the contents of your content block? Commented Mar 2, 2020 at 20:02
  • I updated the question with the code, I'm also in touch with Salesforce support so I can get some more information if there are any error appearing in the logs, I'll keep updated this question if found anything Commented Mar 2, 2020 at 20:24
  • 1
    To get rid of the HTML wrapper, put your content in a code snippet block, not HTML block. Commented Mar 2, 2020 at 20:45
  • 1
    Your script seems to be excluding everything every time. There is no condition as debug is a constant of 1 and your condition excludes the record if debug = 1. Meaning every record would be excluded. Perhaps the issue comes from the fact that you are excluding every single email in the send queue one after the other, which could definitely affect performance especially when utilizing IndexOf - which requires a scan of the entire content block for each and every record after it is rendered - slowing down performance. Commented Mar 2, 2020 at 20:49

1 Answer 1

1

Assuming your content block doesn't include the final exclusion criteria, I'd recommend only returning a 1 (true) or 0 (false). If you do that, you can remove the indexOf from the Exclusion Script.

I believe "no naked personalization strings" is a best practice, so I'd wrap your other system strings in AttributeValue also. If there's any chance that any of them didn't exist in the send context, it'd cause a runtime error and abort the send or pile up the trigger queue.

%%[

    VAR @Debug, @SquadId, @job, @exclude, @MID, @subKey

    SET @Debug = 1
    SET @SquadId = 'DummyValue'
    SET @job = AttributeValue("jobid")
    SET @exclude = 1
    SET @MID = AttributeValue("memberid")

    SET @subKey = AttributeValue('_subscriberkey')

    IF @Debug == 0 THEN

       /* If @whatever == @correct then */
          set @exclude = 0
       /* endif */

    ELSE 
        SET @exclude = 1
    ENDIF

]%%%%=v(@exclude)=%%

Exclusion script:

TreatAsContent(ContentBlockByID(12345))==1

Here's another complex example that I wrote a while back:

EDIT: You'll definitely want to make sure your Content Block is a code snippet type as @Gortonington suggested

1
  • It seems it was a performance issue related to the type of block I was using, I change it to Code Snippet Block and it evaluates fine now. Thank you. Commented Mar 2, 2020 at 23:28

You must log in to answer this question.

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