Copied to clipboard

Flag this post as spam?

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


  • Bo Kingo Damgaard 157 posts 456 karma points
    Aug 24, 2010 @ 13:28
    Bo Kingo Damgaard
    1

    Unable to change document name in Document.AfterSave

    Hi

    Im trying to change the name of the document I'm publishing using Document.Aftersave, but it doesn't seem to work - the name doesn't get changed.

    Document CurrentDocument = new Document(sender.Id);
    CurrentDocument.Text = "Change name to this";
    CurrentDocument.Publish(new User(0));
    umbraco.library.UpdateDocumentCache(sender.Id);

    The funny thing is, that is works if I only save and then publish afterwards, but I can't rely on the client doing that.

    Is it because I do it while publishing the document?

    Regards Kingo

  • Aaron Powell 1708 posts 3044 karma points c-trib
    Aug 24, 2010 @ 13:39
    Aaron Powell
    0

    Try directly interacting with the 'sender' object, rather than creating a new one. The sender object is mutable and I think your problem is that the Save event hasn't completed so it'll trash what you're try to set once the event handler is completed

  • Bo Kingo Damgaard 157 posts 456 karma points
    Aug 24, 2010 @ 13:49
    Bo Kingo Damgaard
    0

    That did the trick.

    It's enogh to change the Text, no need for Publish or UpdateDocumentCache

    Thanks

  • 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