开发者

Kentico TreeNode Delete method not deleting dependencies

开发者 https://www.devze.com 2023-03-21 10:04 出处:网络
I have the following block of code that retrieves a documen开发者_C百科t node in kentico and deletes it. It does delete the kentico node, but not the underlying document type which stays in the datase

I have the following block of code that retrieves a documen开发者_C百科t node in kentico and deletes it. It does delete the kentico node, but not the underlying document type which stays in the datase. Help?!

CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
CMS.TreeEngine.TreeNode image = provider.SelectSingleNode(new Guid(imageID), "en-US", CMS.CMSHelper.CMSContext.CurrentSite.SiteName);

if (image != null)
{
    CMS.TreeEngine.TreeNode school = provider.SelectSingleNode(image.Parent.NodeID, "en-US", true, true);
    if (school != null)
    {
        string CMSUserID = school.GetValue("CMSUserID").ToString();
        if (CMSUserID == ui.UserID.ToString())
        {
            image.Delete(false);                                        
        }
    }
}


You need to use the DeleteDocument method from the CMS.WorkflowEngine namespace. It ensures that all dependent objects are deleted.

DocumentHelper.DeleteDocument(image, provider, true, true, true);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号