In my c# tbb, I am trying to fetch all the components using the particular keyword in a publication context. The code which I am using is:

UsingItemsFilter filter = new UsingItemsFilter(pub.Session)
   ItemTypes = new[] { ItemType.Component },
   IncludedVersions = VersionCondition.OnlyLatestVersions
var classifiedComponents = keyword.GetListUsingItems(filter);

It's filtering all the components which is associated with the particular keyword (suppose i am picking any keyword from the lowest child publication). I assumed, it should be filtered only those components which are in publication hierarchy.

But not, its fetching all components which are also not in publication hierarchy.

Can anyone please suggest, how can i get only those components which are only associated from the publication hierarchy.

2 Answers 2


Since you seem to be interested in classified Components: did you consider using Keyword.GetClassifiedItems ?

  • Thanks Rick. Still I haven't used this method, but I am sure it will also not work. Reason for this assumption is, the extra components which I can see is also classified with that item but those components are not in the context blueprint hierarchy. Commented Nov 25, 2016 at 10:16
  • Try using that method. I think it does exactly what you want. Commented Nov 25, 2016 at 10:36
  • Thanks Rick. Yeah, this method is returning only components which are classified in context to publication blueprint. Commented Nov 27, 2016 at 14:53

Did you try InRepository.

UsingItemsFilter = new UsingItemsFilter(pub.Session)
   ItemTypes = new[] { ItemType.Component },
   IncludedVersions = VersionCondition.OnlyLatestVersions,
   InRepository = new LinkToRepositoryData(){IdRef="tcm:0-{PUB-ID}-0"}
var classifiedComponents = keyword.GetListUsingItems(filter);

I don't have the documentation available but I'm sure I recall that there could be some challenge with localised or shared content so I'd certainly test for local, shared and localised Components (in which case - maybe IncludeLocalCopies = true can be used?).


Actually I just checked something and recalled a similar question when I had problems. There's a full explanation here from Bart.

but essentially you have

  • Drop the InRepository
  • Filter out duplicate item IDs
  • Filter out items from the child Publications
  • Replace the Publication IDs of parent Publications in your context Publication

Or, as you'll see in the post noted above, you could use SearchQueryData but you're relying on the setup of search etc.

  • @Mark, I have already tried InRepository with slightly changed syntax as I am using Tom.Net api(syntax: filter.InRepository=currentPublication). But it is only returning items created or localized in that publication. I have also tried IncludeLocalCopies, but it was also not returning the desired result. Commented Nov 24, 2016 at 18:31
  • Can you eloborate on not returning the desired results ... you state above that the issue is you current receive items "which are also not in publication hierarchy." -> but this solution returns Local and localised items so I would have expected that IncludeLocalCopies would complete the circle and return inherited items - but not those outside the blueprint? Commented Nov 25, 2016 at 12:26
  • @Mark, using IncludeLocalCopies in addition to the code mentioned in the question was also not returning all the component of context publication blueprint. Commented Nov 27, 2016 at 14:42
  • Well I suspect that's the nearest you'll get. You can skip through the response and just remove anything that has "isShared" :) Commented Nov 28, 2016 at 14:28

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.