MarketingAgent - get subscription link

Hi,

is there a possibility to let replace placeholders like [[link.viewShipmentMessage]] (view message online) or [[link.subscription]] (Manage subscription)?

#setLanguageLevel 3;

NSMarketingAgent ma;
NSShipmentMessageEntity sme = ma.GetShipmentMessageEntity(122);  // Fetch template
String html = sme.GetHtmlMessage();  // yields the template HTML containing [[link.viewShipmentMessage]] and [[link.subscription]]
printLine("html=" + html);

The idea is to send emails to customers by using marketing templates instead of reply templates. I get a person_id in my CRMScript of a person having a valid email address. But I need to send the final html containing replacements of the above placeholders, e.g. https://sod.superoffice.com/Cust39315/CS/scripts/customer.fcgi?action=updateSubscriptionsFrame&tk=BB4Wa3t3e31EERwRZBIaZUgbXH4McAh3HHtzVHUbbSoUH...

Best regards, Marc

RE: MarketingAgent - get subscription link

Hi Marc,

It is possible to generate key to use for manage subscription link thru NSPersonAgent, and use Parser to replace variable in html.

Just a quick code example (you need to test this);

#setLanguageLevel 3;
NSMarketingAgent ma;
NSShipmentMessageEntity sme = ma.GetShipmentMessageEntity(2);  // Fetch template
String html = sme.GetHtmlMessage();  // yields the template HTML containing [[link.viewShipmentMessage]] and [[link.subscription]]

Parser p;

NSPersonAgent agent;
Integer personId = 2;
String key = agent.CreateTemporaryKey(1,personId,personId,getCurrentDateTime().addDay(30));

String url = getProgramCustomer() + "?action=updateSubscriptionsFrame&tk=" + key;

p.setVariable("link.subscription", url);
html = p.parseString(html);

print(html);

To replace variable to view in browser, I think best bet is to create your own script to print html and use this link.

 

/Michel

By: Michel Krohn-Dale 7 Sep 2021