Skip to main content
Commonmark migration
Source Link

What you're asking for, doesn't entirely make sense. At least not to me. But let's start with the questions:

##The questions

The questions

Can I create a new Item with a specific ID and branch?

###Can I create a new Item with a specific ID and branch? WellWell you can create a new Item with a specific ID, sure. It will blow up if the ID you're selecting already exists however. It looks like this:

parent.Add("myNewItem", templateID, newItemId);

You could theoretically add information on this newly created Item to indicate a branch, but it would mean nothing at this point. Branches only exist and have an effect when used to create items - not after the fact.

There is no way to specify a Branch Template Id instead of a Template Id in Item creation API. The reason (probably) is; a Branch Template results in not 1 Item but 1..n items.

Can I assign a branch after creating the item?

###Can I assign a branch after creating the item? YesYes, but it would have no effect.

parent.Fields[FieldIDs.Branches].Value = branchId.ToString();

All it would do, is show "created from [your branch]" in the Content Editor. It would have no other effect.

Can I change an Item ID after it is created?

###Can I change an Item ID after it is created? NoNo. Not using official APIs. On a database level, yes, but I strongly advise you not to go there. Doing so would not be supported by Sitecore either.

What you're asking for, doesn't entirely make sense. At least not to me. But let's start with the questions:

##The questions

###Can I create a new Item with a specific ID and branch? Well you can create a new Item with a specific ID, sure. It will blow up if the ID you're selecting already exists however. It looks like this:

parent.Add("myNewItem", templateID, newItemId);

You could theoretically add information on this newly created Item to indicate a branch, but it would mean nothing at this point. Branches only exist and have an effect when used to create items - not after the fact.

There is no way to specify a Branch Template Id instead of a Template Id in Item creation API. The reason (probably) is; a Branch Template results in not 1 Item but 1..n items.

###Can I assign a branch after creating the item? Yes, but it would have no effect.

parent.Fields[FieldIDs.Branches].Value = branchId.ToString();

All it would do, is show "created from [your branch]" in the Content Editor. It would have no other effect.

###Can I change an Item ID after it is created? No. Not using official APIs. On a database level, yes, but I strongly advise you not to go there. Doing so would not be supported by Sitecore either.

What you're asking for, doesn't entirely make sense. At least not to me. But let's start with the questions:

The questions

Can I create a new Item with a specific ID and branch?

Well you can create a new Item with a specific ID, sure. It will blow up if the ID you're selecting already exists however. It looks like this:

parent.Add("myNewItem", templateID, newItemId);

You could theoretically add information on this newly created Item to indicate a branch, but it would mean nothing at this point. Branches only exist and have an effect when used to create items - not after the fact.

There is no way to specify a Branch Template Id instead of a Template Id in Item creation API. The reason (probably) is; a Branch Template results in not 1 Item but 1..n items.

Can I assign a branch after creating the item?

Yes, but it would have no effect.

parent.Fields[FieldIDs.Branches].Value = branchId.ToString();

All it would do, is show "created from [your branch]" in the Content Editor. It would have no other effect.

Can I change an Item ID after it is created?

No. Not using official APIs. On a database level, yes, but I strongly advise you not to go there. Doing so would not be supported by Sitecore either.

Source Link
Mark Cassidy
  • 25.4k
  • 7
  • 59
  • 117

What you're asking for, doesn't entirely make sense. At least not to me. But let's start with the questions:

##The questions

###Can I create a new Item with a specific ID and branch? Well you can create a new Item with a specific ID, sure. It will blow up if the ID you're selecting already exists however. It looks like this:

parent.Add("myNewItem", templateID, newItemId);

You could theoretically add information on this newly created Item to indicate a branch, but it would mean nothing at this point. Branches only exist and have an effect when used to create items - not after the fact.

There is no way to specify a Branch Template Id instead of a Template Id in Item creation API. The reason (probably) is; a Branch Template results in not 1 Item but 1..n items.

###Can I assign a branch after creating the item? Yes, but it would have no effect.

parent.Fields[FieldIDs.Branches].Value = branchId.ToString();

All it would do, is show "created from [your branch]" in the Content Editor. It would have no other effect.

###Can I change an Item ID after it is created? No. Not using official APIs. On a database level, yes, but I strongly advise you not to go there. Doing so would not be supported by Sitecore either.