9

I'm new to Tridion, thanks for your help :-)

I can successfully bind to a service endpoint, validate CoreServiceClient.IsExistingObject("tcm:xx-xxx-xx"), and now I would like to retrieve the version (and other) properties of that item.

How to do this?

8

Welcome to the wonderful world of Tridion... Get ready to go through this cycle a few times in the coming months.

Here's a couple of examples to achieve some of what you're searching for - but not all. Tridion does not store the information you're searching for in the CM, it's only available in Content Delivery - unless you want to do some date comparisons.

First, the basics - read a Component:

var c = (ComponentData)client.Read("tcm:1-2", new ReadOptions());

Read a Component's Version Info:

FullVersionInfo info = (FullVersionInfo)c.VersionInfo;
int currentVersion = info.LastVersion.GetValueOrDefault();

Finding out publishing information about the object involves asking Tridion for some more advanced system data, which is not directly part of the object. In particular, you will want to look at PublishInfoData:

foreach (PublishInfoData p in _client.GetListPublishInfo("tcm:1-2"))
{
    Console.WriteLine("Item was published at {0} to target {1} rendered with {2}",
                       p.PublishedAt.ToShortDateString(),
                       p.PublicationTarget.Title,
                       p.RenderedWith.Title);
}

Have fun, and come back with more questions.

| improve this answer | |
  • Many thanks for your answers, gentlemen, I appreciate it! I actually did try using the Read method, but I got the following exception below. I did "new CoreServicesClient("endpointName")", where "endpointName" is a basicHttp endpoint defined in the appConfig file. Any guesses where I might look next to get this working? Thanks again.... System.ServiceModel.FaultException`1 was unhandled Message=You do not have permission to perform this action. Source=mscorlib StackTrace: Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ... – Ed Prescott Jun 26 '13 at 5:00
  • You should probably ask that as a separate question - might be Tridion or IIS security. This post might help too: code.google.com/p/tridion-practice/wiki/… – Nuno Linhares Jun 26 '13 at 5:54
  • Thanks again, Nuno, I'll do that next time. By the way, the 'You do not have permission..' problem was resolved by adding my user account to the 'Administrators' group. – Ed Prescott Jun 26 '13 at 18:50
  • Glad you got it working, but you shouldn't have to be a windows admin for this. – Nuno Linhares Jun 26 '13 at 20:04
5

This will get you the item

CoreServiceClient.Read("tcm:xx-xxx-xx", new ReadOptions())

If you expect a certain item type you can get the item specific data

var page = (PageData) CoreServiceClient.Read("tcm:xx-xxx-xx", new ReadOptions())

Getting the version The version will be something like

var item = CoreServiceClient.Read("tcm:xx-xxx-xx", new ReadOptions());
var version = item.VersionInfo.Version;

Check the Core Service API reference documentation (chm file) and read about the ICoreService2011 Members and IdentifiableObjectData Members to learn more about CoreService operations and other data properties in the item object.

| improve this answer | |
  • Reading back the question and my answer I realize I did not anwswer the latest published version part of the question :( – Jan H Jun 26 '13 at 9:12

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.