I was looking for a way that how can I fetch all the categories from Tridion using Categoriesdata. I was trying like below, but its showing error.
CoreServiceSession client = new CoreServiceSession();
SessionAwareCoreServiceClient csClient = client.GetClient();
ReadOptions readoption = new ReadOptions();
CategoriesFilterData filter = new CategoriesFilterData();
XElement xml = csClient.GetSystemWideList(filter);
Mark Amery
158k94 gold badges435 silver badges477 bronze badges
asked Aug 23, 2012 at 4:11
SDLBeginner
8571 gold badge8 silver badges20 bronze badges
1 Answer 1
You need to use GetListXml instead of GetSystemWideList and specify the publication ID from which you want to retrieve the categories:
CategoriesFilterData filterData = new CategoriesFilterData();
XElement resultXml = client.GetListXml(publicationId, filterData);
GetSystemWideList is usually for retrieving stuff that is system wide and not bound to just 1 publication, like PublicationTargets and MultimediaTypes
You could however also try a Search query, like so:
SearchQueryData filter = new SearchQueryData();
filter.ItemTypes = new ItemType[] { ItemType.Category };
IdentifiableObjectData[] results = client.GetSearchResults(filter);
foreach (IdentifiableObjectData obj in results)
{
Console.WriteLine(String.Format("{0} - {1}", obj.Title, obj.Id));
}
answered Aug 23, 2012 at 6:24
Reinder Wit
6,6551 gold badge29 silver badges42 bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
SDLBeginner
Thanks Reinder, but what if i need to get all the catagories from tridion not from a specific publication.
Reinder Wit
Ah, OK. you could try using SearchQueryData and search within tridion.
Reinder Wit
like so: SearchQueryData filter = new SearchQueryData(); filter.ItemTypes = new ItemType[] { ItemType.Category }; filter.BaseColumns = ListBaseColumns.Extended; IdentifiableObjectData[] results = client.GetSearchResults(filter);
CoreServiceSessionobject. Just out of curiosity: what is that class and where does it come from? You don't seem to use it.