Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

How to use Duplicate and DuplicateTo

MarcelSzimonisz
Community Advisor
Community Advisor

Hello All,

I have no idea how to use these two. Basically i want to duplicate a record from javascript. Do you have any idea how to use these or how to do it other than manually pass the settings from one to another?

 

Marcel

1 Accepted Solution
isahore
Correct answer by
Level 3
Level 3

Hi @MarcelSzimonisz ,

Here is how you do it in javascript:

I have taken an example of duplicating a delivery template.

 

var del1 = nms.delivery.create();
del1.Duplicate("nms:delivery|<<id of the delivery which you want to duplicate (integer)>>");
del1.save();

 

var del2 = nms.delivery.create();
del2.DuplicateTo("nms:delivery|<<id of the delivery which you want to duplicate (integer)>>","xtk:folder|<<id of the folder to which you want to duplicate your delivery to (integer)>>");
del2.save();

 

After the Duplicate() or DuplicateTo() methods are executed, the newly created delivery (copy of the original one) is available but not saved to the database yet.

Before the .save() you can modify as many properties of the delivery you want to via code as well.

The same way you can use it for other types of entities in Adobe Campaign, provided the schema and id (primary key) are correct.

 

Hope that helps.

Cheers,

Ishan

View solution in original post

7 Replies
DavidKangni
Community Advisor
Community Advisor

Hi Marcel,

 

Duplicate --> let you duplicate an object in the same folder

Duplicate to --> let you duplicate an object to another folder that you will select during the process

 

Thanks

David

MarcelSzimonisz
Community Advisor
Community Advisor
i know this but i cannot get it working from the docu do you have working example?
isahore
Correct answer by
Level 3
Level 3

Hi @MarcelSzimonisz ,

Here is how you do it in javascript&colon;

I have taken an example of duplicating a delivery template.

 

var del1 = nms.delivery.create();
del1.Duplicate("nms:delivery|<<id of the delivery which you want to duplicate (integer)>>");
del1.save();

 

var del2 = nms.delivery.create();
del2.DuplicateTo("nms:delivery|<<id of the delivery which you want to duplicate (integer)>>","xtk:folder|<<id of the folder to which you want to duplicate your delivery to (integer)>>");
del2.save();

 

After the Duplicate() or DuplicateTo() methods are executed, the newly created delivery (copy of the original one) is available but not saved to the database yet.

Before the .save() you can modify as many properties of the delivery you want to via code as well.

The same way you can use it for other types of entities in Adobe Campaign, provided the schema and id (primary key) are correct.

 

Hope that helps.

Cheers,

Ishan

View solution in original post

isahore
Level 3
Level 3

@MarcelSzimoniszcan you tell me what kind of entity you want to duplicate? The below code works for a delivery:

var del = nms.delivery.create();

del.DuplicateTo("nms:delivery|64580475","xtk:folder|56970113"); // example delivery and folder ID used

del.save();

logInfo("new delivery Id: "+del.id);

MarcelSzimonisz
Community Advisor
Community Advisor
ok it is working i was confused with the << >> but the JSAPI there is nothing that you should use it in this way "nms:delivery|" + id. How did you figured this out? 🙂 the documentation says just pk what you want to copy and pk of folder.. thanks a lot
isahore
Level 3
Level 3
I have used it in the past several times, the new API documentation does not have any example for this. I am glad that I could help.