2

I have TCM URI of a Schema, is there any way to get the Schema object from that?

I have tried some code but that only returns the XML of the Schema, I don't know how I can convert it to the Schema object. If I get the Schema object then I can access Schema.NamespaceUri to get the UUID of that Schema.

I am trying the following code but, it only returns the Schema XML.

var resultXml = client.GetListXml(
        publicationId, 
        new RepositoryItemsFilterData 
        {
            ItemTypes = new[] { ItemType.Schema }, 
            Recursive=true 
        }
    ).Elements().Where(schemaElem => schemaElem.Attribute("ID").Value==schemaID);

When I use the following method, it throws an error

var filter = new RepositoryItemsFilterData
        {
            SchemaPurposes = new[] { SchemaPurpose.Metadata },
            Recursive = true,
            ItemTypes = new[] { ItemType.Schema }
        };

var result = client.GetList(schemaID, filter);

Unexpected list type:

Tridion.ContentManager.Data.ContentManagement.RepositoryItemsFilterData.

1 Answer 1

6

If you are using Coreservices try this.

SchemaData schema = (SchemaData)client.Read("Your Id", new ReadOptions());
3
  • worked, thank you. If i understand correctly, I can use read method to get information of any object by passing TCM ID in the parameter, Right?
    – Ali
    Commented Sep 4, 2013 at 1:25
  • right, it will return a IdentifiableObjectData instance, IdentifiableObjectData is the base class for all the tridion items so you need to cast it.
    – Eric Huiza
    Commented Sep 4, 2013 at 1:27
  • 1
    Indeed CoreServiceClient.Read is going to return info about any item in Tridion with a TcmUri given that the user doing the operation has necessary permission.
    – Likhan
    Commented Sep 4, 2013 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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