10

We have a scenario where we will get an Item Id of a particular Component from its parent level. We basically want to know whether that Component is published (in a child Publication), and if it is, we want to republish it.

We are getting these Components (the parent URIs) from UsingItemsFilterData, and we observed that the Item XML contains an IsPublished attribute, and its value is always False (correct as this item is from the parent level and it cannot be published on that level). But this particular Component is published in a child Publication.

So using the parent level Component URI, we need to find out if that particular Component is published or not on a lower BluePrinted level.

We are using SDL Tridion 2011 SP1 and a .Net client application using Core Services.

5
  • Have you tried setting the InRepository value in your filter to the TcmUri of the child Publication you want the results from? Commented Jun 5, 2013 at 15:27
  • Yes, We had tried InRepository prop in my filter but it targets only the given publication. But we need all list of publications where ever the component is published. Commented Jun 6, 2013 at 8:59
  • Thanks for your reply... After much research, we found a property "Purpose = ResolvePurpose.RePublish" in ResolveInstruction , which helps us to fulfil our requirement. Commented Jun 6, 2013 at 9:10
  • Good to hear you solved it, can you reword that in the form of a full answer and answer your own question with that for future reference (and accept it then also)? Commented Jun 6, 2013 at 9:18
  • Sure Bart Koopman.. Commented Jun 6, 2013 at 9:30

4 Answers 4

7

We know it's possible, because the UI does it ("Published To" tab on the Where Used view).

You can use client.GetListPublishInfo(string itemId) to get this list.

Something along these lines:

foreach (var p in client.GetListPublishInfo("tcm:89-16029"))
{
    Console.Write("Item published to target {0} with template {1} on {2} from publication {3}.",
                               p.PublicationTarget.Title, p.RenderedWith.Title,
                               p.PublishedAt.ToShortDateString(), p.Repository.Title);
}
1
  • Thanks for your reply Nuno.. Yes, It also gives us full info. But we tried with another way to fulfil our goal/requirement. I've answered my question, you can please find my answer.. Commented Jun 6, 2013 at 9:42
5

You need to make sure that the Component is viewed in the context of the Publication you expect it to be published to.

You can do this using the tip in Bart's comment, or simply swap the Publication ID part of the TCM URI and re-fetch the Component: e.g. tcm:14-999-16, means the Component is in context of Publication 14, but if you're publishing it from, say, Publication 15, just do a string replace to make it tcm:15-999-16.

4

Our goal is to publish only previously published items in all publications.

var pubData = new PublishInstructionData()
{
    ResolveInstruction = new ResolveInstructionData() { 
        IncludeChildPublications = true, 
        IncludeComponentLinks = true, 
        Purpose = ResolvePurpose.RePublish
    },
    RenderInstruction = new RenderInstructionData()
};

try
{
    //ItemsToBePublished is a list of item ids which we need to publish..
    if (ItemsToBePublished.Any() && PublishingTargets.Any())
        CoreService.Publish(ItemsToBePublished.ToArray(), pubData, PublishingTargets, PublishPriority.Low, null);
}
catch (Exception ex)
{
    //Exceptions handling goes here..
}
1
  • Yup, this will work for RE-publishing items, since that's the standard behavior for the resolver. Good one.
    – Nuno Linhares
    Commented Jun 6, 2013 at 12:23
3

Apart from Bart's comment, I would like to share some more information:

If you are accessing the Component on a specific Publication and now you want to find whether that Component is published

  • To a specific target, use

    • IsPublished(itemId, publicationTargetId, isPublishedInContext)

      Here set isPublishedInContext as True

  • To any target, use
    • IsPublishedInContext
1
  • Thanks for your answer Siva.. IsPublished gives us the published status of an item from only the level which the id is given.. But our requirement is to find the item's published status from parent level too. And then we need to republish only those items, which were published previously.. We have done our requirement by another way using a single property. You can please take a look at my answer to my question below :-) Commented Jun 6, 2013 at 9:54

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.