3

The OnComponentSave Event couldn't be triggered and no error is raised.

Below is the detailed code. The "initialized" and "event be subscribed" info can be found inside the Application log, but the "save component completed" message never is displayed. No other error or warning can be found neither. Any idea what's wrong here?

[TcmExtension("My Tridion Event System")]
public class Events : TcmExtension
{
    public Events()
    {
        Logger.Instance.LogInfo("Initialized");
        Subscribe();
    }

    public void Subscribe()
    {
        try
        {
            EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSaved, EventPhases.Initiated);
            Logger.Instance.LogInfo("Event be subscribed");
        }
        catch (Exception ex)
        {
            Logger.Instance.LogError("Error : " + ex.Message);
            throw ex;
        }
    }

    private void OnComponentSaved(Component component, SaveEventArgs args, EventPhases phase)
    {
        Logger.Instance.LogInfo("Save component started");
    }

}
  • did you try after restarting the SDL Web Service Host and IIS App Pool? – Pankaj Gaur Nov 22 '16 at 4:59
  • Please note, the first two logs will get logged at the very first moment the DLL loads (or I can say after the TCM Service Host resets). and the third log will generated every time you try to save a component. So in case there is a weird Cache at IIS or in case you have updated the DLL but did not reset the TCM Service Host – Pankaj Gaur Nov 22 '16 at 5:01
  • I see you're using the Initiated event state. Have you tried with the TransactionCommitted phase? docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v1/… – robrtc Nov 24 '16 at 13:51
5

You do not say in your question that you have actually saved a component to test this. I'm going to assume that you have, but it's also possible that the server where you saved the component is not the one where you have the events system installed/configured.

This could easily happen in a scaled-out scenario.

| improve this answer | |

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.