Error while deleting un-published page

Brijesh Singh asked on December 20, 2017 14:30

Team,

While deleting unpublished page, I am getting below error. Can you please advise?

Code: var docs = DocumentHelper.GetDocuments() .Published(false);

    foreach (var treenode in docs)
    {
        treenode.Delete();
    }

Error:

[BaseInfo.Delete]: Object ID (MenuItemID) is not set, unable to delete this object.

at CMS.DataEngine.BaseInfo.Delete() at CMS.DocumentEngine.TreeNode.DeleteInternal() at CMS.DocumentEngine.TreeNode.Delete(Boolean useDocumentHelper) at CMS.DocumentEngine.DocumentHelper.DeleteDocument(DeleteDocumentSettings settings) at CMS.DocumentEngine.DocumentHelper.DeleteDocument(TreeNode node, TreeProvider tree, Boolean deleteAllCultures, Boolean destroyHistory, Boolean deleteProduct, String webRootFullPath, ArrayList deletedNodeIDs) at CMS.DocumentEngine.TreeNode.Delete(Boolean deleteAllCultures, Boolean destroyHistory, Boolean deleteProduct) at CMS.DocumentEngine.TreeNode.Delete(Boolean useDocumentHelper) at CMS.DocumentEngine.TreeNode.Delete() at Admin_Default.OnPreInit(EventArgs e) in d:\K8_Backup\CMS\Admin\Default.aspx.cs:line 35 at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thx.

Recent Answers


Zach Perry answered on December 20, 2017 23:34

Can you try deleting with DocumentHelper.DeleteDocument(treenode);

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.