12

I am trying to delete a couple of publication targets but am getting a warning saying This item is in use. The location of my publication targets no longer exist so unpublishing using the target fails.

How can I delete the Publication Target?

  • 2
    You can point it to a new, empty, deployer and unpublish from that one... – Nuno Linhares Mar 23 '13 at 17:31
  • @NunoLinhares Just to be clear, I'd have to set up a new content delivery server? If so, this is not an option available to me. – Kevin Brydon Mar 25 '13 at 9:51
  • I would install it on my own laptop, point the target to it, unpublish, delete it... – Nuno Linhares Mar 25 '13 at 10:38
  • "Any reason why this would cause problems down the line?" -> If you get your data into some sort of inconsistent state because of this, you're on your own. – Nuno Linhares Mar 25 '13 at 12:23
  • @NunoLinhares I should have guess that would be the only sensible answer! I've sent a support request to SDL Support so maybe they can help. I'll update once I've got a response. – Kevin Brydon Mar 25 '13 at 12:25
13

There will be items that are published to the publication target. I would do the following:

  1. Open the publication target
  2. Look at the publications assigned to the target
  3. For each publication - right click and unpublish selecting the target (also select structure groups to ensure everything is removed from the target)
  4. Once complete try again to delete

I wouldn't recommend manually changing something in the database to 'trick' the delete.

  • Thanks. I'm pretty sure this answers my question. Just got to solve another problem before I can actually try it... – Kevin Brydon Mar 22 '13 at 15:33
  • Ok. Unpublishing doesn't work as the location in my publication doesn't actually exist. I guess it needs somewhere to send the packet. Not sure whether to update this question or ask a new one... – Kevin Brydon Mar 22 '13 at 16:30
  • Hi @KevinBrydon - I'll update my answer a little to add some more suggestions – johnwinter Mar 26 '13 at 14:52
7

IMPORTANT

Although this solved my problem, I'd advise anyone with a similar problem to first try the suggestions from Dominic, Trevor, Nuno and John. And as Bart has just pointed out, only after Customer Support have told you to do this. You have been warned.


I contacted SDL Support and they advised me to make a backup of the Content Manager Database and then run the following UPDATE commands

UPDATE ITEM_STATES
SET STATE = 0
WHERE
    PUBLICATION_TARGET_ID = @MyPublicationTargetID
    AND STATE = 1

UPDATE PUBLISH_STATES
SET STATE = 0
WHERE
    PUBLICATION_TARGET_ID = @MyPublicationTargetID
    AND STATE = 1

This sets the published status to "unpublished" for all items associated with a particular publishing target. I was then able to delete the publication target through the Content Manager Explorer.

  • 4
    Agreed, it's good to know this works, but executing any database query on the CMS database without having told to do so by Customer Support, voids your warranty. – Bart Koopman Mar 25 '13 at 16:32
6

Even after all the content is unpublished, make sure all the Target Types and publication associations are removed. I remember that being a sticking point for me.

  • If the target no longer exists for unpublish...I used the TOM.COM to set the status of the item. Something like: page.SetPublishedTo(target.Attributes["ID"].Value, false, tdse.User.ID); should work. – Trevor Bartlett Mar 22 '13 at 18:11
  • I have a slight problem. After following Dominic's advice I know what items are published. Unfortunately some are components and they don't have the SetPublishedTo method available. – Kevin Brydon Mar 25 '13 at 9:55
6

Sometimes the only way to get the necessary information is a bit of database digging. First, of course, clean up all the obvious things - make sure nothing's published to it, remove any publish transactions, etc. If all that doesn't work, try the following:

In the database, examine EDA_PUBLICATION_TARGETS_DELETE - observe that it begins with several selects which need to come up empty. Execute these same selects by hand, and check what items, if any, are found. If you find any items, you will probably find that you can delete them perfectly cleanly without modifying anything in the database yourself. Just instantiate each object from the API and use the .Delete() method.

  • Thanks Dominic, I now know what items are published to the unwanted targets. However when I try to delete then I get an error saying that I cannot delete because the item is published. – Kevin Brydon Mar 25 '13 at 9:57
  • If they are component presentations, the setPublishedto method is on the componentTemplate. – Dominic Cronin Mar 25 '13 at 14:05
  • It would seem it is the actual component that is published. It's not part of a page, componentTemplate, componentPresentation etc. – Kevin Brydon Mar 25 '13 at 14:13
  • Do a where-used on the component and have a look in the published-to tab. There you should see any dynamic component presentations listed. – Dominic Cronin Mar 25 '13 at 15:43
6

OK, I'm a bit upset that:

  1. Customer Support gave you a SQL query that might break in different versions of the CM (that's why we have APIs that cover pretty much anything you can do in Tridion)
  2. You decided to publish that SQL query here. Someone is bound to try that on a different version of Tridion and get weird results

You could have achieved the same result with the following code:

TDSE tdse = new TDSE();
Console.WriteLine(tdse.User.Name);

PublicationTarget target = tdse.GetObject("tcm:0-1-65537", EnumOpenMode.OpenModeView);
ListRowFilter listRowFilter = tdse.CreateListRowFilter();
listRowFilter.SetCondition("OnlyPublishedItems", true);

XmlNamespaceManager nm = new XmlNamespaceManager(new NameTable());
nm.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
Dictionary<string,ComponentTemplate> componentTemplates = new Dictionary<string, ComponentTemplate>();
foreach (Publication p in target.AllowedPublications)
{
    XmlDocument publishedItems = new XmlDocument();
    Console.WriteLine(listRowFilter.GetXML());
    publishedItems.LoadXml(p.GetListPublishItems("tcm:0-1-65537", false, false, ListColumnFilter.XMLListDefault, listRowFilter));
    foreach (XmlNode node in publishedItems.SelectNodes("tcm:ListPublishItems/tcm:PublicationTarget/tcm:Page", nm))
    {
        Page page = tdse.GetObject(node.Attributes["ID"].Value, EnumOpenMode.OpenModeView);
        Console.WriteLine("Resetting published status of " + page.Title);
        page.SetPublishedTo(target, false, tdse.User);
    }
    foreach (XmlNode node in publishedItems.SelectNodes("tcm:ListPublishItems/tcm:PublicationTarget/tcm:Component", nm))
    {
        Component component = tdse.GetObject(node.Attributes["ID"].Value, EnumOpenMode.OpenModeView);
        foreach (XmlNode ctNode in node.SelectNodes("tcm:RenderWith", nm))
        {
            string ctId = ctNode.Attributes["ID"].Value;
            if (!componentTemplates.ContainsKey(ctId))
            {
                ComponentTemplate ct = tdse.GetObject(ctId, EnumOpenMode.OpenModeView);
                componentTemplates.Add(ctId, ct);
            }
            Console.WriteLine("Resetting published status of " + component.Title + " (with template " + componentTemplates[ctId].Title + ")");
            componentTemplates[ctId].SetPublishedTo(component, target, false, tdse.User);
        }
    }
}
  • Should I remove my answer or maybe just the SQL? I have pointed out that if someone tries to run the query they risk voiding their warranty. I appreciate the API way is the more sensible way to solve my problem. I'll run it an see what happens. – Kevin Brydon Mar 26 '13 at 9:33
  • You can keep it, but please add a pretty big disclaimer that this script is intended for Tridion 2011 and there's no guarantees it will work in other environments. – Nuno Linhares Mar 26 '13 at 9:40
  • Just realised, I'll be a couple of weeks before I can test ... got to restore the test database and I'm on holiday from Wednesday – Kevin Brydon Mar 26 '13 at 9:42

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.