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 1470 posts 3427 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 1470 posts 3427 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 81 posts 255 karma points
    Jul 14, 2023 @ 09:13
    Asembli
    0

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

    Regards

  • Tim 43 posts 197 karma points
    Nov 07, 2023 @ 14:00
    Tim
    0

    Also broken for several of the member events as well.

Please Sign in or register to post replies

Write your reply to:

Draft