Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amigo 231 posts 506 karma points
    Mar 15, 2011 @ 10:42
    Amigo
    0

    copy and delete documents

    Hi,

    1/
    Im trying to copy and publish a document, but the new copy does not get published, i wonder why:
    User user = new User(0);
    Document doc = new Document(intId);
    doc.Copy(GetCustomerOfferNode(), user);
    doc.Publish(user);
    umbraco.library.UpdateDocumentCache(doc.Id);
    umbraco.library.RefreshContent();
    BindGridData();

    2/
    When deleting documents "UpdateDocumentCache" and "RefreshContent" dosent seem to work propperly.
    Because when rebinding my grid from a datatable with ChildrenAsTable() my deleted document still shows in my grid... why is that??
    Document doc = new Document(intId);
    doc.delete();
    umbraco.library.UpdateDocumentCache(doc.Id);
    umbraco.library.RefreshContent();
    BindGridData();

  • Amigo 231 posts 506 karma points
    Mar 15, 2011 @ 11:11
    Amigo
    0

    I found a solution to problem1:
    Document doc = new Document(intId);
    doc.Copy(GetCustomerOfferNode(), user, true);
    foreach (Relation r in Relation.GetRelations(doc.Id, RelationType.GetByAlias("relateDocumentOnCopy")))
     {
           Document newDoc = new Document(r.Child.Id);
           newDoc.Publish(newDoc.User);
           umbraco.library.UpdateDocumentCache(newDoc.Id);
           r.Delete();
    }

    BindGridData();

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies