Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:25:39+00:00 2026-06-07T12:25:39+00:00

After a Tridion CMS Database restore from another environment we cannot unpublish Components from

  • 0

After a Tridion CMS Database restore from another environment we cannot unpublish Components from the Broker. If we publish to the Broker then we can unpublish. We want to set the IsPublishedTo status to the publish targets available in the new envioronment.

The TOM API has a SetPublishedTo method available for Pages and Component Templates but not Components.

How can I set the PublishedStatus for the Components? Is it possible using UpdateXML or do we need to perform database black magic?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:25:40+00:00Added an answer on June 7, 2026 at 12:25 pm

    I use the following C# based code in a command line tool for switching the PublishStates of all my items after a SDL Tridion 2009 environment switch (What version are you using?):

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Tridion.ContentManager.Interop.TDS;
    using Tridion.ContentManager.Interop.TDSDefines;
    using System.Xml;
    
    namespace SetAllItemsAsUnpublished
    {
        /// <summary>
        /// A command line script that can enable/disable users
        /// </summary>
        class Program
        {
            static void Main(string[] args)
            {
    
                TDSE tdse = new TDSE();
                User currentUser = tdse.User;
                ListRowFilter listRowFilter = tdse.CreateListRowFilter();
                String xpath = "/tcm:ListPublishItems/*/*[local-name()='Page' or local-name()='Component']";
                listRowFilter.SetCondition("Recursive", true);
                listRowFilter.SetCondition("OnlyPublishedPages", true);
                listRowFilter.SetCondition("OnlyPublishedCPs", true);
    
    
                //listRowFilter.SetCondition("ItemType", ItemType.ItemTypePage);
    
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
                nsmgr.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
    
                //Check that the user running the script is an Administrator
                if (currentUser.privileges == TDSPrivileges.TdsPrivilegeSystemAdministrator)
                {
                    Publications publications = tdse.GetPublications();
                    Console.WriteLine("There are " + publications.Count + " to be processed");
                    int i = 0;
                    foreach (Publication publication in tdse.GetPublications())
                    {
                        ++i;
                        Console.WriteLine(" - Processing " + publication.Title + "(" + i + " of " + publications.Count + ")");
                        foreach( PublicationTarget target in tdse.GetPublicationTargets()){
                            Console.Write("     checking target: " + target.Title);
                            XmlDocument publishedItemsXml = new XmlDocument();
                            try
                            {
                                publishedItemsXml.LoadXml(publication.GetListPublishItems(target.ID, false, false, ListColumnFilter.XMLListID, listRowFilter));
                                foreach (XmlElement publishedItemNode in publishedItemsXml.SelectNodes(xpath, nsmgr))
                                {
                                    String uri = publishedItemNode.Attributes["ID"].Value;
                                    Console.Write(".");
                                    if (publishedItemNode.LocalName == "Page")
                                    {
                                        Page page = (Page)tdse.GetObject(uri, EnumOpenMode.OpenModeView, publication, XMLReadFilter.XMLReadAll);
                                        page.SetPublishedTo(target, false, currentUser);
                                        if (page.Info.IsCheckedOut)
                                        {
                                            page.CheckIn(true);
                                        }
                                    }
                                    else
                                    {
                                        foreach (XmlElement ctRenderNode in publishedItemNode.SelectNodes("tcm:RenderWith", nsmgr))
                                        {
                                            String uriCT = ctRenderNode.Attributes["ID"].Value;
                                            ComponentTemplate ct = (ComponentTemplate)tdse.GetObject(uriCT, EnumOpenMode.OpenModeView, publication, XMLReadFilter.XMLReadAll);
                                            ct.SetPublishedTo(uri, target, false, currentUser);
                                            if (ct.Info.IsCheckedOut)
                                            {
                                                ct.CheckIn(true);
                                            }
                                        }                                
                                    }
                                }
                                Console.WriteLine();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                        }
                    }
                }
                else
                {
                    //Warn when there is a non-admin user running the script
                    Console.WriteLine("You must be an SDL Tridion CMS Administrator to run this application");
                }
                Console.WriteLine();
                Console.WriteLine("Done! Hit ENTER key to close");
                Console.ReadLine();
            }
        }
    }
    

    So basically setting the CT to UnPublished should do what you need, as the Component is not technically published, it is a Component Presentation based on that CT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After constructing the bean, I want to retrieve data from the database, using the
I am using C# code and Tridion(CMS) classes to fetch data from Tridion, below
After some time researching and trying different things I still cannot get my @ExceptionHandler
After following the RoR getting started tutorial, I added another model as: $ rails
After following: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview I can sign up a user via Facebook. But I'm struggling
After updating from ruby-1.8.7-p352 to ruby-1.8.7-p358 via rvm , gems are still installed to
After merging a branch, do you delete it from the repository? Is it a
After using the following code no errors are shown, but my database is not
After switching my Rails 2.3 app from MRI Ruby 1.8.7 to JRuby 1.6.5, the
After debugging a CodeIgniter application that were installed into a new development environment, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.