3

I'm looking to create a piece of software that will allow my organisation to rename existing components in Tridion, find where they are used, update the references to those components and automatically republish the pages.

I'm really early in the investigation and I have no idea if it is even possible.

So, my question is, what APIs (preferably WebServices) can I used to find Schemas in Tridion, is there a "where used" type API that I can call and finally, does anyone have experience of this kind of activity?

Thanks Marc

8

The first thing that strikes me about your question is that there is already a tool to do most if not all of those things - The Content Manager Explorer! "Don't re-invent the wheel!" (just playing Devil's advocate here).

The API you will most likely want to use is the Core Service. This is a WCF web service that you can use to communicate with Tridion. The CME itself uses the Core Service, so anything you can do there manually can be done programmatically (plus lots more!).

A simple "where used" query to find components based on a specified schema in Core Service using a .Net client would typically look something like:

var filter = new UsingItemsFilterData {
    ItemTypes = new[] { ItemType.Component }
};
var components = client.GetList(schemaId, filter);
  • Thanks David. Believe me I don't want to reinvent the wheel if possible. I was advised that Content Manager Explorer wasn't a valid route because of manual republishing. The key thing for this work is to automatically republish all the pages where the component is used as you can image there will be a lot. Can this still be done in the Explorer? – Marc Thomas May 27 '15 at 9:52
  • 1
    Sure, it's possible. Out of the box, when you publish a component, the standard Tridion resolver will find the pages that the component is used on and publish those, along with any possible dynamic component presentations. So the only manual step would be to publish the component after updating it. – David Forster May 27 '15 at 9:55
  • +1 to @DavidForster's comment. Between Where Used and Advanced Search in the CME, you can queue Components for publishing quite quickly. – Alvin Reyes Jun 1 '15 at 12:10
2

These days there are specific methods in the Core Service to synchronize Components with their Schemas: SynchronizeWithSchema and SynchronizeWithSchemaAndUpdate.

For more information, see "Synchronizing a content item and its Schema using the Core Service" in the documentation.

1

You will want to write a recursive method using the WhereUsed API and then, depending on the type of item you get back (Page or Component) continue the loop, or if it is a Page, exit or add it to a list and then continue. Then, after this is finished, publish each page in the list. It is completely possible in the API. However, you might get a lot of relations, so testing it with a good content set would be a good idea.

I'd also suggest to provide some kind of feedback to the users. If you implemented a .Net web service on top of the Core Service then you could expose some methods to be called from JavaScript via Ajax and provide feedback to the user.

It's not a small task and I'd take some time to think about the recursion and the filters needed in the WhereUsed call.

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.