Dynamic delivery creation using js in adobe campaign classic | Community
Skip to main content
Level 4
April 15, 2024
Solved

Dynamic delivery creation using js in adobe campaign classic

  • April 15, 2024
  • 1 reply
  • 1571 views

Hello everyone,

I'm attempting to create dynamic deliveries containing personalized attachments and HTML content for each recipient. I've tried achieving this by selecting depending on recipient profiles in delivery, but I haven't been successful in testing it.

So, I've decided to use JavaScript instead. With the code below, I've managed to personalize content and attachments for a single customer. However, I want to extend this to all my recipients. I need one delivery that contains all my recipients, with each receiving individual personalized attachments and content.

Could anyone help me sort this out?

 

var rId = '1234';
var subjectLine = 'Hi im working';
var xmlTargeting = <delivery>
<targets >
<deliveryTarget>
<targetPart exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={'@id=' + rId}/> // Recipient ID
</where>
</targetPart>
</deliveryTarget>
</targets>
<mailParameters>
<subject>{subjectLine}</subject>
</mailParameters>
</delivery>;

var template = 'tempInternalName';

var finalDev = nms.delivery.CreateFromModel(template, xmlTargeting); // Delivery Template internal name

var deliv = nms.delivery.create(finalDev);

deliv.scheduling.validationMode = "auto";

deliv.validation.useBudgetValidation = false;

deliv.validation.useContentValidation = false;

deliv.validation.useTargetValidation = false;

deliv.validation.useFCPValidation = false;

deliv.content.html.source = '<html> <body>Hello Test</body> </html>';

var recId = 'test_1234';

deliv.attachment.add(
<attachment compressMode="print" filterActive="false" label="CRM test.csv"
nameScriptActive="false" type="normal" upload="false">
<name>C:\Program Files (x86)\Adobe\Adobe Campaign v7\var\cc_sandbox\export\{recId}.txt</name>
</attachment>
)

deliv.hasAttachments = true;

deliv.save();

nms.delivery.PrepareFromId(deliv.id);

 

Regards,

Sujith Kumar.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by CampaignerForLife

You've two things to do: 

<where> <condition expr={'@id=' + rId}/> // Recipient ID </where>

This is where the query to recipients is being made, you've to change it so it gets all the recipients you want (If you want to get all recipients you should remove this where condition).

 

Second, here: 

deliv.content.html.source = '<html> <body>Hello Test</body> </html>';

You've to add the personalization fields you want. This is the literal message that will be sent, so if you add something like 

<%= recipient.firstName%>

 It will be personalized in each delivery. 

1 reply

CampaignerForLife
CampaignerForLifeAccepted solution
Level 5
April 22, 2024

You've two things to do: 

<where> <condition expr={'@id=' + rId}/> // Recipient ID </where>

This is where the query to recipients is being made, you've to change it so it gets all the recipients you want (If you want to get all recipients you should remove this where condition).

 

Second, here: 

deliv.content.html.source = '<html> <body>Hello Test</body> </html>';

You've to add the personalization fields you want. This is the literal message that will be sent, so if you add something like 

<%= recipient.firstName%>

 It will be personalized in each delivery. 

Level 4
July 17, 2024

Hi @campaignerforlife ,

 

Sorry for late reply. I was looking for dynamic attachment it may be any type. Thanks for your reply I solved it using file class js.

 

Regards,

Sujith Kumar