I am currently working on a Proof of Concept using the Data Exchange. I have implemented the demo from the Sitecore Documentation.

The example is working as expected. However, I need to create subitems based on a Branch Template but I don't know how since I just started working on the Data Exchange Framework.

So, in brief, I have a Container in the Sitecore Content Tree. Under the Container, the Data Exchange will create the items. Right now, all items are being created under the container. I need to have the item structure as below:

enter image description here

Can anyone provide a sample code or link to achieve this. I am new to Data Exchange.

1 Answer 1


After lot of investigation, I have seen that the Branch Template cannot be used since I get the following error:

Template is invalid (cdbb9572-14b6-4ea2-818e-bb6c15beda94)

The reason is because of the Add Method from the namespace


Below is the Code for creating the item:

public Guid Add(ItemCreateRequest request, string databaseName, string language)
  Database database = ItemRepository.GetDatabase(databaseName);
  Language language1 = ItemDataBase.GetLanguage(language);
  Item obj = database.GetItem(request.ParentPath, language1);
  if (obj == null)
    throw new ArgumentException(ItemDataBase.InvalidParameterMessage("Path", (object) request.ParentPath));
  TemplateItem template = database.GetTemplate(new ID(request.Template));
  if (template == null)
    throw new ArgumentException(ItemDataBase.InvalidParameterMessage("Template", (object) request.Template));
  Item itemToUpdate = obj.Add(request.Name, template);
  using (new EditContext(itemToUpdate))
    this.UpdateFields(request.Fields, itemToUpdate);
  return itemToUpdate.ID.Guid;

The above code is used for creating an item from a template and not from a Branch Template. For Branch Template it should have been as below:

private const string _BRANCH_ITEM = "/sitecore/templates/Branches/MyBranches/MyBranch";

public void Create(Item parent, string name)
   BranchItem branch = globalDataFolder.Database.GetItem(_BRANCH_ITEM);
   Assert.IsNotNull(branch, "Could not find Data branch at " + _BRANCH_ITEM);
   parent.Add(name, branch);

The difference is instead of using TemplateItem, it need to be changed to BranchItem in order to create item from Branch Template. Example is taken from Brian Pedersen post

It seems that the only way to achieve this is to override the ItemRepository and implement a new method that caters for Branch Template. Maybe, introducing the creation of items from Branch Template in future releases of the Sitecore Data Exchange Framework might be considered.

  • 1
    hello i am looking for this solution.The answer "override the ItemRepository and implement a new method that caters for Branch Template" makes sense.Can you let m eknow how to override the itemrepository and where to configure? Where should i add the code.can you eloborate solution. Commented Feb 27, 2018 at 18:39
  • It's been a while since I have not check this code. You may need to search for the pipeline ItemRepository and add in your custom code. Commented Feb 27, 2018 at 18:42
  • Preferably ask a new question Commented Feb 28, 2018 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.