Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

Dynamic delivery creation using js in adobe campaign classic

Avatar

Level 3

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 7

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. 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

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. 

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