Duplicating a record

A small post, but it could be a real timesaver. Do all you boys and gals actually know how easy it is to create a duplicate of a record? Here's a small example how:

C#
1
2
3
4
5
6
7
8
9
10
11
12
// First loading the record to copy
Record record = new Record(app);
record.Load(new Guid("13E8571C-233B-410d-A81F-A8643AA7455E"));

// Duplicating this source record (only in memory at this point)
Record duplicate = new Record(app);
duplicate.AddNew(record);

// At this point you can change the duplicate-instance as you please.

// Saving the duplicate to the database.
duplicate.Save();

The important line is the AddNew-method call. This single line copies all classifications, fields, files, versions, previews of the source record to this instance. Any files used by the source record will also be automatically copied in the Save-method. The biggest advantage of this approach is that, after the AddNew-call, you can still modify the duplicated record as you please before saving it. At that point, you could reclassify, change field values, add or remove other files... Anything you can do with any ordinary record is possible at that point.

Comments

Leave a comment
You must be logged in to post comments.
Sign in now
 
 
CATEGORIES
AnnouncementsDocMaker StudioEngineSharePoint ConnectorWeb DevelopmentWebinarsWorkflow Studio
rss feed