Reputation: 612
I am quite new to Tridion core service so this might be a simple question. I want to get all metadata schemas by passing a publication ID. If some one has ever done this please reply.
Thanks in advance
Upvotes: 6
Views: 776
Reputation: 4316
Okay, here is an example. GetCoreServiceClient returns a SessionAwareCoreServiceClient with Impersonate already called for the correct user.
public static IdentifiableObjectData[] GetMetadataSchemas(string publicationId)
{
using (var client = GetCoreServiceClient())
{
var filter = new RepositoryItemsFilterData
{
SchemaPurposes = new[] { SchemaPurpose.Metadata },
Recursive = true,
ShowNewItems = false,
ItemTypes = new[] { ItemType.Schema }
};
return client.GetList(publicationId, filter);
}
}
Upvotes: 10
Reputation: 2444
I will suggest you to look sample code from [here][1](Login required) and try your self first.
[http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/concept_95D8F90693834AF089FEBCDC0347D04D][1]
or try this.
RepositoryItemsFilterData filterData = new RepositoryItemsFilterData();
filterData.ItemTypes = new[]
{
ItemType.Schema
};
filterData.Recursive = true;
XElement resultXml = client.GetListXml(publicationId, filterData);
And then you need to create each schema object after getting ids from above xml and check whether it is metadata schema.
Upvotes: 10