Typology Rule not pulling Recipient.id to Personalise a WebApp URL
Hello Adobe Campaign Community,
I am hoping someone from the Adobe Campaign Community might be able to help with bizzar issue I am facing.
Let me try explain the issue.
What I am trying to do:
For One-Click Unsubscribe (Gmail and Yahoo requirement) I am building a typology rule which will add SMTP header to all new email deliveries.
Adobe provided Typology rule code for MailTo SMTP header, but I am changing bit of code to include Recipient’s EncryptedID (Or ID) to the URL so when a user clicks on the Unsubscribe link on Gmail, the URL has recipient’s ID which we can use to identify the recipient and unsubscribe them.
The change I have added to the Typology rule is that I am checking if “delivery.mapping.schema” is equal to “nms:recipient”. If so, I am building headerUnsubUrl with recipient encryptedID to be passed in SMTP header. Else I am passing only MailTo SMTP header. In below example I am using recipient.id as it is also giving me same error. The code is like this:
var deliveryMappingSchema = delivery.mapping.schema;
logInfo("---Delivery Mapping Schema is: " + deliveryMappingSchema);
if (deliveryMappingSchema == "nms:recipient"){
logInfo("Mapping Schema of this delivery is nms:recipient");
var headerUnsubUrl ="https://yourdomain.com/webApp/oneClickUnsub?id=<%= recipient.id%>>, <mailto:<%@ include option='NmsEmail_DefaultErrorAddr' %>?subject=unsubscribe<%= escape(message.mimeMessageId) %>";
else {
logInfo("Mapping Schema of this delivery is Unknown");
var headerUnsubUrl ="mailto:<%@ include option='NmsEmail_DefaultErrorAddr' %>?subject=unsubscribe<%= escape(message.mimeMessageId) %>";
}
What is the Issue:
All is working fine in UAT. When I send email to Gmail, I see Unsubscribe link and I am able to unsubscribe using the link. The link has recipient.id which was passed by the Typology rule.
The issue I am facing for Client A is when I am moving Typology code into Prod Instance. When I create a new recipient delivery with amended Typology rule (which is working fine in UAT), the delivery is failing with error:
Error while compiling script 'SMTP headers' line 4: recipient is not defined. SCR-160012 Javascript: error while evaluating script 'SMTP headers'.
Some reason it is not recognising the recipient schema, hence not passing recipient.id. Same error is happening if I use custom schema too.
I tried same solution on another Client’s Prod instance (Client B), although it is creating the delivery (No error like above) and email is going out, but some reason the id is “undefined” in SMTP header of the email I received.
https://yourdomain.co.uk/webApp/oneClickUnsub?id=undefined
Has anyone seen this issue?
The marketing instances are hosted by Client (Not Adobe). Architecture wise both are same for Client A where email is failing with an error.
For Client B, the only difference between UAT and Prod I can see is that the “Publication Option for Web forms and surveys” is Local on UAT (Deployment Wizard > Access from Internet configuration), but in Prod the publication mode is setup to be “Other Adobe Campaign Server(s)”, but the setup of "Internal URLs of frontal server" is the Adobe Campaign Web Server.
Can someone suggest why I am facing issue on Prod only and not on the UAT? What I can check/change on Prod Adobe servers to make it work?
Any other suggestions are also welcome. E.g. how you created solution for One-click Unsub using Adobe based WebApp.
Thank you so much for your help
Nagender