I'm having trouble understanding the upcoming change to how Marketing Cloud will interpret subject lines containing inline AMPScript or personalization strings. As from Feb 21, 2023, Marketing Cloud will stop processing nested AMPscript in email subject lines.
The example they provide in this knowledge article states:
subject: %%=V(@subject)=%%
HTML body:
%%[
SET @dealType = Lookup("Deals", "DealType", "DealCode", DealCode)
SET @subject = "Check out the latest deals on %%=V(@dealType)=%%!"
]%%
...will resolve as:
Check out the latest deals on %%=V(@dealType)=%%!
However, the documentation goes then explains if you're using personalization strings as subject lines, for example %%Subject%%
, will also "result in nested personalization within the subject line" (i.e. it will break), but the workaround is to wrap the attribute with a TreatAsContent
function, for example:
%%=TreatAsContent(Subject)=%%
Now that you're up to speed with this imminent change, I'm trying to understand whether the following pattern will be affected by this update. I'm using the following subject line:
%%=TreatAsContent(@subject)=%%
And I have some AMPscript code in my email body looks something like this:
%%[
var @subject
set @subject = Lookup('SubjectLines', 'Subject', 'Email', emailName_)
]%%
And the Subject field in the DE might contain the value:
Thanks for supporting %%ChildFirstName%%
My question is, how will my subject line be interpreted with this change? The docs explain that email subject lines are currently processed twice to parse nested variables/AMPscript. I get that. But is my subject line considered as a double pass? I think it might be. And if this subject line will be interpreted as:
Thanks for supporting %%ChildFirstName%%
...then what is the best workaround for subject lines that are stored in a DE field which contain inline AMPscript or personalization strings?
I'm guessing that the following workaround might do the trick, but in absence of more elaborate documentation, this is really just an assumption:
subject: %%=v(@subject)=%%
HTML body:
%%[
var @subjectStr, @subject
set @subjectStr = Lookup('SubjectLines', 'Subject', 'Email', emailName_)
set @subject = TreatAsContent(@subjectStr)
]%%