4

I would like to get the shared Pages for a Localized Component in WhereUsed with the Core Service. (The Page is created in a Parent Publication and shared, and the Component is Localized.)

The following code works and returns the Pages for the Component when the Page and Component are both created in the same Publication, but it does not return any Pages when the Component is on the Page in the parent Publication. I have a feeling I need another Filter, as that's usually the special sauce that makes the GetListXml sing.

Update: If I do not use the InRepository flag then I do get the Page, but in a Parent Publication. Then I could manipulate the URI and get my local Page. In my Blueprint scenario it works ok. Thoughts?

string compUri = "tcm:42-424242";
var comp = (ComponentData) client.Read(compUri, new ReadOptions());
LinkToRepositoryData pub = comp.LocationInfo.ContextRepository;
UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
{
    BaseColumns = ListBaseColumns.Default, 
    ItemTypes = new[] { ItemType.Page, ItemType.Component},  
    InRepository = pub,    
    IncludedVersions = VersionCondition.OnlyLatestVersions
};

XElement usingXML = client.GetListXml(compUri, usingItemsFilterData);
  • Try removing the "InRepository" condition from your filter. – Nuno Linhares Nov 27 '14 at 13:20
  • I tried that and it gives me the parent Page – robrtc Nov 27 '14 at 14:19
  • I recall there was a BlueprintChainFilter for this. You also specify the direction (Asc or dsc). – Nickoli Roussakov Nov 27 '14 at 14:45
2

The UsingItems list returns the items in their "owning repository" by design. Indeed, you don't want to use the InRepository condition, because that filters on "owning repository" (and for shared items, the "owning repository" is per definition not the same as the context repository).

You can indeed change the TCM URI of all item to be in the context repository (any item which is not already in the context repository will be from a repository higher in the Blueprint chain and thus will also exist in the context repository). Note, however, that this won't always be correct: suppose that a Page contains your Component higher up in the BluePrint and is localized in your context Repository, where it doesn't contain your Component anymore. The UsingItems list will return the Page that contains your Component higher up in the BluePrint. However, if you then change the TCM URI of the Page to be in the context Repository, you are addressing the local copy of the Page, which didn't contain your Component.

1

I guess, comp.LocationInfo.ContextRepository returns the publication where the item is created. So if its returning the results from the publication where the component is created, its expected.

if you want to get pages from the publication where the component is localized, you can try using somthing like LinkToRepositoryData pub = comp.BlueprintInfo.OwningRepository to get the results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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