When you insert an element into Sitecore, you use the following code:
Item newItem = parentItem.Add("NameOfNewItem", template);
Then you edit the item.
Then you save the item.
If the error occurs in the middle, AFTER the parentItem.Add command parentItem.Add fields of the new element are not saved, but the child element is created and placed in the content tree anyway, so we have an incomplete element in (really wrong).
Is it possible to insert an element in these lines?
- create item
- fill item
- finally add the filled item to the content tree.
In other words, is there a way to put parentItem.Add at the end of the whole process?
This will really help improve data integrity.
source share