EventMessage not shown when cancelling a move operation
I have a legacy v7 site for which we need to cancel any move operations for certain doctypes unless the user is in certain groups.
Using a ContentService.Moving event handler we can cancel the move easy enough however the event message does not bubble up the UI and the move action gets confirmed with a success message even though the node was not moved. Here is the event handler...
private void ContentServiceOnMoving(IContentService sender, MoveEventArgs<IContent> e)
{
var restrictedDoctypes = new[]
{
Blog.ModelTypeAlias,
NewsSection.ModelTypeAlias,
PressRelease.ModelTypeAlias
};
var doctypesBeingMoved = e.MoveInfoCollection.Select(d => d.Entity.ContentType.Alias);
if (!restrictedDoctypes.ContainsAny(doctypesBeingMoved) || !e.CanCancel) return;
e.CancelOperation(new EventMessage("Content Permissions", "You do not have permission to move this type of document", EventMessageType.Error));
}
I have also tried the following with no success:
e.Cancel = true;
e.Messages.Add(new EventMessage("Content Permissions", "You do not have permission to move this type of document", EventMessageType.Error));
Any ideas on how to force this message up to the UI?
One year later, the problem still exists in v13.4.1.
Are there so few developers who use ContentMovingNotification and want to cancel it with an error message that this is simply irrelevant?
Is there a workaround?
I think this was pushed to the back burner because of the back office rewrite. I think they felt there was no point trying to fix the older implementation (which seems to have some inconsistencies, which is why some events work and others don't) if they were rewriting most of it anyway.
I've not tested V14 to see if they've sorted this as part of the rebuild or not. I'd be interested to see if it has or not. Ideally someone needs to test out all of the events and see which ones work and which ones don't I think. I identified a bunch of member events that have similar issues, as well as some other areas too.
EventMessage not shown when cancelling a move operation
I have a legacy v7 site for which we need to cancel any move operations for certain doctypes unless the user is in certain groups.
Using a
ContentService.Moving
event handler we can cancel the move easy enough however the event message does not bubble up the UI and the move action gets confirmed with a success message even though the node was not moved. Here is the event handler...I have also tried the following with no success:
Any ideas on how to force this message up to the UI?
Looks like it is a known bug and the pull request to fix it was never merged: https://github.com/umbraco/Umbraco-CMS/pull/3599
Unfortunately, this still seems broken in V10.4.0.
And also in V12.0.1. The same for copying...
Regards
Also broken for several of the member events as well.
One year later, the problem still exists in v13.4.1. Are there so few developers who use ContentMovingNotification and want to cancel it with an error message that this is simply irrelevant? Is there a workaround?
I think this was pushed to the back burner because of the back office rewrite. I think they felt there was no point trying to fix the older implementation (which seems to have some inconsistencies, which is why some events work and others don't) if they were rewriting most of it anyway.
I've not tested V14 to see if they've sorted this as part of the rebuild or not. I'd be interested to see if it has or not. Ideally someone needs to test out all of the events and see which ones work and which ones don't I think. I identified a bunch of member events that have similar issues, as well as some other areas too.
Dominic, it looks like a PR was merged that fixes this in 13.6 something! Might be worth checking out to see if it resolves your issue.
is working on a reply...