Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 09, 2022 @ 09:50
    Simon Dingley
    0

    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?

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Nov 09, 2022 @ 10:59
    Simon Dingley
    0

    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

  • Peter van den Dungen 66 posts 365 karma points
    Feb 20, 2023 @ 13:28
    Peter van den Dungen
    0

    Unfortunately, this still seems broken in V10.4.0.

  • Asembli 85 posts 259 karma points
    Jul 14, 2023 @ 09:13
    Asembli
    0

    And also in V12.0.1. The same for copying...

    Regards

  • Tim 45 posts 199 karma points
    Nov 07, 2023 @ 14:00
    Tim
    0

    Also broken for several of the member events as well.

  • Dominic Resch 45 posts 115 karma points
    Sep 16, 2024 @ 14:47
    Dominic Resch
    0

    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?

  • Tim 45 posts 199 karma points
    Sep 17, 2024 @ 13:13
    Tim
    0

    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.

  • Tim 45 posts 199 karma points
    Sep 17, 2024 @ 13:24
    Tim
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft