Hello I'm using Tridion 2011 and I need to get all the components from a specific publication and based on a specific schema in C#. Does anyone knows how to do it? Thanks in advance.
2 Answers
You can do it using CoreService like:
var filter = new UsingItemsFilterData
{
InRepository = new LinkToRepositoryData {IdRef = "%pubId%"},
ItemTypes = new [] {ItemType.Component }
};
var list = ClientAdmin.GetList("%schemaId%", filter);
-
Thanks for the answer. Which DLL's and/or usings should I use to use those methods? Mar 11, 2016 at 8:15
-
Tridion.ContentManager.CoreService.Client.dll . It is our public API. You can read more about it by: docs.sdl.com/LiveContent/content/en-US/… Mar 11, 2016 at 8:28
Not sure why you want to do that and where you want to do that (in TBB or Custom application or just want to review/make a list of those items for something). Apart from above answer which seems absolutely fit for the purpose if you want to do that in a custom application for some custom business logic. There are another way you can do thats:
- Use Advanced Search in CME - and select the publication, type of item and based on Schema to get a list of items:
- Further, you can choose to save this filter/query as a Virtual Folder - which you can access similar to a Folder listing all items based on your query. Also, you can code to read the content of this Virtual Folder using Core Service (in custom applications) or using TOM.NET API (in TBBs or Event System)