2

I have a schema id. based on that schema id i want to retrieve all components modified date (created by that schema).

How to resolve it?

  • Is there a reason that they are not already on the Page as Component Presentation's? Normally, if you want to render a Component at publish time you would have it as a Component Presentation on the Page already. – Chris Morgan Jul 1 '15 at 19:15
  • no components are not added in component presentation directly...in component presentation i have added one component,in that component i have given one schema tcm id, based on that tcm id i have to retrieve components.. – Sudip Ghorai Jul 2 '15 at 19:05
  • As tagged (templating) this question is not a duplicate of tridion.stackexchange.com/q/2320/46. This question can be improved, though. Sudip, please include what you've tried and maybe what you're expecting. You've provided background that this is a templating question for Razor Mediator, which is a good start. But the community will not generally write code for you; rather they can guide you and clarify parts you don't understand, especially if you've researched and given it some effort. – Alvin Reyes Jul 9 '15 at 17:00
2

You can get a list of components wich uses that schema by this TOM.NET code:

UsingItemsFilter filter = new UsingItemsFilter(schema.Session);
filter.ItemTypes = new List<ItemType> { ItemType.Component };
filter.IncludedVersions = VersionCondition.OnlyLatestVersions;

IEnumerable<IdentifiableObject> components = schema.GetUsingItems(filter);

Then, for each component of the returned list you can retrieve the propertiy "RevisionDate".

Also you cas use Tridion CoreService to obtain the list of components based on that schema:

SearchQueryData query = new SearchQueryData() {
    BasedOnSchemas = new BasedOnSchemaData[] { 
        new BasedOnSchemaData(){ 
            Schema = new LinkToSchemaData(){ IdRef= "{schemaId}" }
        }
    },
    SearchIn = new LinkToIdentifiableObjectData() { IdRef = "{publicationId}" }, 
    ItemTypes = new ItemType[]{ ItemType.Component }
};

XElement xResults = channel.GetSearchResultsXml(query);

This is from this post: How to get all Components based on a Schema and from a particular Publication?

Hope it helps.

| improve this answer | |
  • Hi Julian. Thanks for helping out here by copying the answer. What we generally prefer, though, is to flag the question as a duplicate. This gives people a better chance of finding high-quality answers on the site. – Dominic Cronin Jul 2 '15 at 10:43
  • Sorry, you're right. I flag it. – Julián Hernández Jul 2 '15 at 10:51
  • whether the "schema" filed in above expression will bethe name of the schema or TCM id of the schema? – Sudip Ghorai Jul 2 '15 at 12:51
  • In the first sample is a schema object: Schema schema = (Schema)_Engine.GetObject(YourSchemaUri); – Julián Hernández Jul 2 '15 at 13:28
  • I am not geeting the components by 1st code..pls help me out – Sudip Ghorai Jul 2 '15 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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