Search code examples
tridiontridion-2011

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


Solution

  • 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);
        }
    }