SDL Developer
SDL Developer

Reputation: 612

Get all metadata schemas of a publication

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

Answers (2)

Peter Kjaer
Peter Kjaer

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

vikas kumar
vikas kumar

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

Related Questions