kamagra how much to take

SharePoint Taxonomy Error: Terms can not be shared multiple times in the same term set

So let’s assume you have the following situation. You have two term sets. We will call them TermSetXand TermSetY. In TermSetY, you are reusing a TermX from TermSetX. Now let’s assume that you want to reuse a TermY from TermSetX in TermSetY as a child of TermX.

When I was trying to do this I immediately thought the to use the ReuseTerm method (TaxonomyInternalService.ReuseTerm). ReuseTerm is exposed in the TermSetItem concrete class which is used as by the Term and TermSet derived classes. The utility of ReuseTerm is it allows a specification of a source term that is the target for resuse, and return a new Term from the caller TermSet.

If you try to do this quickly you might end up with code like I did, similar to:

  1. if(TermSetY.GetTerm(TermY.Id) == null)
  2. TermX.ReuseTerm(TermY, false);

You may encounter the error:

Error: Microsoft.SharePoint.Taxonomy.TermStoreOperationException: Terms can not be shared multiple times in the same term set

To solve the error, simply lean on the original ReuseTerm method:

  1. Term termXReference = null;
  2. if (termSetY.GetTerm(termX.Id) == null)
  3. {
  4. termXReference = termSetY.ReuseTerm(termX, false);
  5. }
  6. if (termXReference == null) termSetY.GetTerm(termA.Id);
  7.  
  8. if(termSetY.GetTerm(termY.Id) == null)
  9. var termYReference = termXReference.ReuseTerm(termY, false);
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>