How to Customize Sitecore Copy operation

28 views Asked by At

I am trying do Customization for the copying operation. when editors are doing item copy operation (Right Click Item > Copying > CopyTo), I need to restrict when the selected item having morethan two child levels then, I need to show a warning/Message "Item copying is failed". can you anyone suggest me, how can achieve this.

image here

just I want to restrict the operation when child item leave is >2

1

There are 1 answers

0
mikaelnet On

The best way is probably to override the existing Sitecore.Shell.Framework.Commands.CopyTo command and implement your own QueryState logic, where you basically just test if context.Items[0] has more than two levels. Having a message appear might be tricky, so I'd suggest having the QueryState method return Disabled instead. You should probably avoid traversing the item tree when testing how many levels you got. Traversing the item tree can be very slow if there are many items. Do some Solr Query for this instead.

Once you have your own CopyTo command, patch the type attribute in <command name="item:copyto"> configuration with your own class.