I'm listening to Document events to do "stuff" everytime a document is published, unpublished and deleted, and those event handlers I need to have the document url.
I have no problem in the AfterPublish and AfterUnPublish events: I get the url of the document with the following line
umbraco.library.NiceUrlWithDomain(sender.Id)
But I cannot find a way to get the url of document when it's being deleted:
I've tried getting it in the AfterUnPublish, in the BeforeUnPublish and in the BeforeMoveToTrash, but I always get an error when calling the NiceUrlWithDomain.
Couldn't find any page with the nodeId = 1059. This is most likely caused by the page isn't published! Parameter name: nodeId
This is weird because in theory in the BeforeMoveToTrash nothing should have happened yet, so the document should still be published. And yes, for those wondering, the BeforeUnPublish/AfterUnPublish events happen after the MoveToTrash events.
Any idea how I can get the url of the document being deleted?
Bug. To make it short, deleting a node ends up doing
calls to legacyAjaxCalls.Delete
which calls dialogHandler_temp.Delete
which calls contentTasks.Delete
which first calls library.UnPublishSingleNode, thus removing the node from the XML cache
and then calls Document.Delete, thus triggering BeforeMoveToTrash
So when BeforeMoveToTrash runs, the node has not "officially" been trashed, but it's been removed from the XML cache and you can't get its url anymore. No idea why it works that way. Can't see any workaround either because BeforeMoveToTrash really is the first event to trigger.
How to get to url of node when it's being deleted
Hi all,
I'm listening to Document events to do "stuff" everytime a document is published, unpublished and deleted, and those event handlers I need to have the document url.
I have no problem in the AfterPublish and AfterUnPublish events: I get the url of the document with the following line
umbraco.library.NiceUrlWithDomain(sender.Id)
But I cannot find a way to get the url of document when it's being deleted:
I've tried getting it in the AfterUnPublish, in the BeforeUnPublish and in the BeforeMoveToTrash, but I always get an error when calling the NiceUrlWithDomain.
Couldn't find any page with the nodeId = 1059. This is most likely caused by the page isn't published!
Parameter name: nodeId
This is weird because in theory in the BeforeMoveToTrash nothing should have happened yet, so the document should still be published. And yes, for those wondering, the BeforeUnPublish/AfterUnPublish events happen after the MoveToTrash events.
Any idea how I can get the url of the document being deleted?
Thank you
Simone
A bit more debugging: the document.Published property is still True
Wondering if this is a bug
Which version of Umbraco?
When you mean "deleted" do you mean "moved to trash" or "actually deleted"?
Version 4.10
Moved to trash
Bug. To make it short, deleting a node ends up doing
So when BeforeMoveToTrash runs, the node has not "officially" been trashed, but it's been removed from the XML cache and you can't get its url anymore. No idea why it works that way. Can't see any workaround either because BeforeMoveToTrash really is the first event to trigger.
OK... looks like a bug :)
Will store the URL myself somewhere..
thx
Simone
is working on a reply...