4

How to get "where used" status of component, component template, page template , schema etc. as "true" or "false" using tridion core service.I am currently using

 UsingItemsFilterData filter = new UsingItemsFilterData();
 filter.ItemTypes = new[] { ItemType.Page};
 IEnumerable<XNode> nodes = Client.GetListXml(componentUri, filter).Nodes();

The above code returns the actual where used items details, instead of "true" and "false".It has following drawbacks.

  1. I just need the status as "true" and "false" . As the complete data is returned, it is very slow
  2. If the returned data is too much. I get a "Query Timeout" error at Tridion database layer. Following stored procedure SQLUtilities.OpenRecordsetByStoredProcedure gives this error.

Please provide a method which just returns where used status.

3
  • 1
    When should true or false be returned? The thing is that most of the items have some objects that are using it. Commented Feb 18, 2015 at 12:07
  • I need to identify the components, component templates, page templates, schemas etc. which are not in use. To get this list I want to get the where used status of the items as "true" or "false". Commented Feb 18, 2015 at 12:10
  • Interesting use case for "is used" rather than "where used." Commented Feb 18, 2015 at 17:19

4 Answers 4

6

There is no such method in the Core Service API. If there was, I suspect that Tridion would probably still be doing similar operations in the database to determine whether an item is used or not, so it would still take time.

Your code is currently filtering on pages only. For a true "Where used" status you probably need to remove the item types from your filter. Also consider setting the filter's IncludeLocalCopies property to true. I would suggest something like the following:

UsingItemsFilterData filter = new UsingItemsFilterData {
    filter.BaseColumns = ListBaseColumns.Id;
    filter.IncludeLocalCopies = true;
}
var isUsed = (Client.GetList(componentUri, filter).Length != 0);

If you can use the TOM.Net API on the server itself rather than the Core Service, then there is a method on IdentifiableObject called HasUsingItems() which may help you.

0
5

There's no built-in method for it, but you may limit the amount of data returned by setting filter.BaseColumns = ListBaseColumns.Id

3

If you want to check if an item is in use so you can determine that you can delete the item, I would just suggest to execute the delete on it. The delete will automatically return you a failure if the item is in use, and if it isn't in use, the delete will be successful.

But if your intention is just to have a result so you can set an indication of it, then you are bound to the available methods in our API, which will return you a list.

0

The only way to determine if an item is used, is to get the list of items that use it, and check whether the amount is zero. (Imagine that you only listed the top 10 using items.... you couldn't say whether the item were in use or not.)

Having said that, "Where used" queries are among the heaviest database queries in Tridion (resolving queries are the other heavy category). The documentation for your system gives advice on maintaining your database for optimal Tridion use. In particular, the regular updating of your database's optimizer statistics is an essential item of maintenance. Where-used queries suffer badly if your administrator fails to take care of this. If you are getting time-outs, that's very likely an indicator that you should check that the documentation is being correctly followed.

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.