I have an event handler that I was using in 4.7.2 to cancel the deletion of a Document, but this is no longer working in the way in which I would expect in 6.1.1.
When this event hanlder fires, the page is not deleted which is fine, but the message that is displayed to the content editor is "Error Handling Action - No node exists with the id '0'", and I get an error thrown by /umbraco/webservices/legacyAjaxCalls.asmx/Delete.
My event handler looks something like this:
public PreventContentDeletionEventSubscriber()
{
Document.BeforeMoveToTrash += new Document.MoveToTrashEventHandler(Document_BeforeMoveToTrash);
}
protected virtual void Document_BeforeMoveToTrash(Document Sender, umbraco.cms.businesslogic.MoveToTrashEventArgs e)
{
if (IsRelated(Sender.Id))
{
e.Cancel = true;
}
}
I have had a couple of my other event handlers require changes based on upgrading to 6.1.1 so I'm hopeful that this is another instance where I need to change my event handler.
I've not tried this, but just a thought, does this still happen if you remove the call to your IsRelated function? Perhaps the error could be coming from there?
Thanks for your reply. Yeah I did try this, I've found that the issue is e.Cancel, not the IsRelated method. I took IsRelated out when testing, the same thing happens.
After some further investigation I think it is how I'm registering my event handlers. I've put an event handler that cancels deletion into a fresh install and the error doesn't occur.. However, there is no visual feedback that deletion has been cancelled - it just looks like it has deleted the node. This doesn't feel like a big deal, but I think it's important for the editor to be aware that their action hasn't been completed.
This is the same for Media, and I had raised an issue on this in September (http://issues.umbraco.org/issue/U4-758), but I've just updated it to be for both Media and Content.
I've found a nasty workaround for now - rather than cancelling the event, you can throw an exception which will put the exception title in a speech bubble on the screen.
This is certainly not a long term solution, however I suspect that this bug isn't high priority with Belle on the horizon so will have to do for the time being.
I've tracked the original error back to a different event handler - so there the only issue is that the tree shows the node as being deleted and no speech bubble is displayed to show the action was cancelled.
Cancelling deletion with Event Handlers in 6.1.1
I have an event handler that I was using in 4.7.2 to cancel the deletion of a Document, but this is no longer working in the way in which I would expect in 6.1.1.
When this event hanlder fires, the page is not deleted which is fine, but the message that is displayed to the content editor is "Error Handling Action - No node exists with the id '0'", and I get an error thrown by /umbraco/webservices/legacyAjaxCalls.asmx/Delete.
My event handler looks something like this:
I have had a couple of my other event handlers require changes based on upgrading to 6.1.1 so I'm hopeful that this is another instance where I need to change my event handler.
Has anyone else come across this?
Thanks!
A little digging around and it appears that this has been an issue in 4.9.0 so I wonder if this issue and the one I'm experiencing are related?
http://issues.umbraco.org/issue/U4-889
Hi,
I've not tried this, but just a thought, does this still happen if you remove the call to your IsRelated function? Perhaps the error could be coming from there?
-Tom
Hi Tom
Thanks for your reply. Yeah I did try this, I've found that the issue is e.Cancel, not the IsRelated method. I took IsRelated out when testing, the same thing happens.
Gotcha - if the barebones code is failing, might be worth reporting an issue on the issue tracker then.
You could also try checking the log in /App_Data/LOGS to see if there's a stacktrace or anything when that error gets hit, might give a clue.
After some further investigation I think it is how I'm registering my event handlers. I've put an event handler that cancels deletion into a fresh install and the error doesn't occur.. However, there is no visual feedback that deletion has been cancelled - it just looks like it has deleted the node. This doesn't feel like a big deal, but I think it's important for the editor to be aware that their action hasn't been completed.
This is the same for Media, and I had raised an issue on this in September (http://issues.umbraco.org/issue/U4-758), but I've just updated it to be for both Media and Content.
I've found a nasty workaround for now - rather than cancelling the event, you can throw an exception which will put the exception title in a speech bubble on the screen.
This is certainly not a long term solution, however I suspect that this bug isn't high priority with Belle on the horizon so will have to do for the time being.
I've tracked the original error back to a different event handler - so there the only issue is that the tree shows the node as being deleted and no speech bubble is displayed to show the action was cancelled.
Thanks for the update - just upvoted.
is working on a reply...