5

Having trouble digging certain Publication Target elements out using C# I want to get the following:

  • Allowed Publications
  • Allowed Target Types
  • Minimal Approval Status

I was able to get most everything else. Here is my code so far:

enter image description here

  • 1
    It would be much better if you could include your code as text instead of with a screenshot. It would be much easier to read, guaranteed to always be available (not so with an image), would show up in search results, and readers can actually highlight/copy/quote the text. You can click on the "help" link next to the input textbox to see the markup to use for code. Thanks! – Peter Kjaer Sep 26 '13 at 9:24
  • Good point Bart. Will do next time. Appreciate your feed back. – BryanD Sep 27 '13 at 15:08
5

All lists in returned from Tridion are partially loaded, ie. not all of the properties will be returned. This is done to reduce load on both database and application server and also to reduce the traffic size. Depending upon the filter class you are using you can set some additional columns to be preloaded, in addition to all filter classes having BaseColumns which works with a limited set of properties. So, you have to use the list and then to retrieve everything of that item you will have to do another read operation of the item itself as @eric mentions.

foreach (PublicationTargetData t in targets)
{
  PublicationTargetData target = (PublicationTargetData) client.Read(t.Id, new ReadOptions());
  // You should be able to access all the properties here, however keep in mind any references you have to other Tridion objects will be links with Id and Title for eg. Publication, Target Types and Approval Stats
}
  • I just need to keep digging to figure out the patterns. I will add your feed back to my notes as well. Thanks. – BryanD Sep 27 '13 at 15:15
5

You can try this:

PublicationTargetData publicationTarget = (PublicationTargetData)channel.Read("[PublicationTargetId]", new ReadOptions());

IEnumerable<PublicationData> publications = publicationTarget.Publications.Select(s => (PublicationData)channel.Read(s.IdRef, new ReadOptions()));
IEnumerable<TargetTypeData> targetTypes = publicationTarget.TargetTypes.Select(s => (TargetTypeData)channel.Read(s.IdRef, new ReadOptions()));
ApprovalStatusData approvalStatus = (ApprovalStatusData)channel.Read(publicationTarget.MinApprovalStatus.IdRef, new ReadOptions());

This code will retrieve the actual Tridion objects. The CoreServices API will give you LinkTo[TridionObjectType] references instead of direct references to Tridion objects like the TOM .Net API because of performance reasons, remember that the CoreServices is a SOAP web service that needs to send information in a distributed environment and reducing the messages sizes is critical.

Having said that, in case you really need access to the actual Tridion object you can always use the IdRef property available in all the LinkTo[TridionObjectType] to retrieve the object. For instance for a Publication you will have a LinkToPublicationData object.

IEnumerable<LinkToPublicationData> links = publicationTarget.Publications;

You can iterate though it to convert them into actual PublicationData objects.

IEnumerable<PublicationData> publications = links.Select(s => (PublicationData)channel.Read(s.IdRef, new ReadOptions());

I hope this helps.

  • Great info. This did help. Seems like it would be easier to query directly to the db. This is a "no no" though. Thank you Eric – BryanD Sep 27 '13 at 15:13

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.