When you insert an item in Sitecore you use a code like this:
Item newItem = parentItem.Add("NameOfNewItem", template);
Then you edit the item.
Then you save the item.
If an error happens in the middle, AFTER the parentItem.Add instruction, the fields on your new item are not saved, but the child item is created and placed in the content tree anyway, so we have an incomplete item in the content tree (really wrong).
Is there anyway to insert an item on this lines?
- create an item
- populate the item
- finally, add the populated item to the content tree.
In other words is there any way to put the parentItem.Add instruction at the end of the whole process?
That would really help to improve data integrity.
You are basically asking for a way to use transactions for the creation of the item.
This isn’t supported with Sitecore 6. It was mentioned (a couple years ago) that Sitecore 7 will support transactions.