0

I need to execute a logic before the Sitecore item deletion event or before Sitecore shows delete warning. I am trying

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
    <events>
    <event name="item:deleting" >
      <handler type="PH.Foundation.Extensions.Pipelines.CustomDeleteHandler, PH.Foundation.Extensions" method="OnItemDeleting" "/>
      
    </event>
    </events>
</sitecore>

but it executes after the Sitecore delete warning. How can I execute it before the delete warning or how can I edit the processor where sitecore shows a delete warning

enter image description here

1 Answer 1

3

In order to achive this you can patch your implementation for the custom processor before the below pipeline.

<configuration>
 <sitecore>
   <processors>
    <uiDeleteItems>
       <processor type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckPermissions" mode="on"/>
    </uiDeleteItems>
   </processors>
 </sitecore>
</configuration>

This pipeline is responsble for triggering Delete confirmation message. You can create a custom processor and patch it above the DeleteItems processor under the uiDeleteItems pipeline as below.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
    <sitecore>
       <processors>
            <uiDeleteItems>
                <processor patch:before="*[@method='CheckPermissions' and @type='Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel']" mode="on" type="{{Custom_ProcessorClass}}" method="{{Custom_MethodName}}" />
            </uiDeleteItems>
       </processors>
    </sitecore>
</configuration>

Hope this helps!!!

4
  • i have used this and it looks as expected in show config but when I try to delete any item it gives error System.Reflection.TargetParameterCountException Message: Parameter count mismatch. My class and method is as below public class CustomDeleteHandler { public void OnItemDeleting(object sender, EventArgs args) { Item item = Event.ExtractParameter(args, 0) as Item;}} Commented May 31 at 12:27
  • @Vinesh you need to change the code as well.. It will not use the event handler code..Check the Sitecore.Shell.Framework.Pipelines.DeleteItems class inside Sitecore.Kernel dll there you will get to know how to read the cuurent item parameter inside the CheckPermissions method. Let me know in case you have any doubts
    – ckhanna
    Commented May 31 at 12:43
  • Thanks for your help, It's working now Commented May 31 at 12:59
  • Great @Vinesh!!!
    – ckhanna
    Commented May 31 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.