2

I'm trying to do implement some logic while a particular template item is getting published. To implement this logic I started exploring the Sitecore Powershell's Event Handlers. For the events like item:added, item:copied events I'm successfully able to get the output for the events, but for the Publish event like publish:begin, publish:end I'm not able to get any output from the result.

Below are the steps which I've followed to enable Sitecore Powershell events.

  1. Created the Patch file for Spe.Event.config
  <sitecore role:require="Standalone or ContentManagement" security:require="Sitecore">
    <events>
      <event name="publish:begin">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
      <event name="publish:end">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
      <event name="item:added">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
      <event name="user:created">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
      <event name="publish:startPublishing">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
    </events>
  </sitecore>
</configuration>
  1. Then I've created a module by following these steps, created Event Handlers with the help of this article
  2. When I tried for the first time it was not successful and found out the solution here but when I try the same for Publish events it's not working Sample Script

Can some please assist me to figure out what mistake is being done here. Thanks in advance.

3
  • 2
    From the screenshot the Events module is not yet enabled. There is a checkbox. – Michael West Dec 20 '20 at 14:08
  • @MichaelWest Upon checking the item I couldn't find the checkbox for enabling it. Can you please name the Field name? Also when I created the script for item:added event I haven't done for enabling it. – Gowthamaraja Eswaramoorthy Dec 20 '20 at 14:44
  • @MichaelWest Thanks for the information. Events are triggered after enabling the checkbox of the Events Module. – Gowthamaraja Eswaramoorthy Dec 21 '20 at 2:22
4

As mentioned by Michael West, the enable checkbox is not checked. You need to activate it for the events to triggered.

Select the item Events and you will see a section named Module Activation. Check the enabled checkbox. Below is a screenshot.

enter image description here

1
  • Thanks Walid and Michael West. After enabling the checkbox my events are getting triggered. – Gowthamaraja Eswaramoorthy Dec 21 '20 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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