When creating a bcp package using the bcpToolkit .NET library the iterationNumber is currently resetting for each revision. If not handled in the code this can cause a violation of unique key constraint (Exception: ImportItemDataFromXMLFailed )
in the DTU when importing the package into Vault because the iterationNumber has to be unique inside an itemMaster.
For a guide on how to get started with the bcpToolkit .NET library please refer to the Getting Started section on the coolOrange wiki.
Add an Item
After you have created the Visual Studio project and followed the required steps, add an item to the package passing the required parameters. The item gets added with its first iteration.
var itemMaster = bcpService.ItemService.AddItem("ItemNumber", "category", "title", "desc");
Add another revision
Now another revision can be added which creates a new iteration of the item.
var itemRevision = itemMaster.AddRevision("rev1", "rev1desc");
Automatically handle item iterations
Now with 2 item revisions you can add following line of code to get the highest iteration number of the item and add +1 to the latest iteration
itemRevision.Iterations.Last().IterationNumber = itemMaster.Revisions.SelectMany(rev => rev.Iterations).Max(iter => iter.IterationNumber) + 1;
bcpToolkit .NET library (coolOrange Wiki)
IItemService Interface (coolOrange Wiki)