I have created a sample event system code to update a field of a Component when it is using a particular Schema.

  1. DLL created and deployed properly

  2. Added the assemblyFileName in to the config as well

Source code of the event system:

namespace com.jio.events.ComponentEventHandler
    public class ComponentEventHandler : TcmExtension
        public ComponentEventHandler()
            EventSystem.Subscribe<Component, SaveEventArgs>(SetOrUpdateMetadataProduct, EventPhases.TransactionCommitted);

        private void SetOrUpdateMetadataProduct(Component component, EventArgs args, EventPhases phase)
            if (component.Schema.Equals("XSLT Test - Ignor")) 
                ItemFields content = new ItemFields(component.Content, component.Schema);
                SingleLineTextField title = (SingleLineTextField)content["Title"];
                //XhtmlField extra = (XhtmlField)content["extras"];

                title.Value = "Mobile";
                //extra.Value = "test done";
                component.Content = content.ToXml();

I'm a bit surprized looking at your code sample, since component.Schema.Equals("XSLT Test - Ignor") is marked as a suspicious comparison in my Visual Studio (but that might be an addon I use).

Your problem is definitely in this line, you seem to assume that component.Schema is the Schema title. If you would use the TOM.NET API guide, you will see that it actually is an object of type Tridion.ContentManager.ContentManagement.Schema and that has a property Title which is a string.

So you should try using the following instead:

if (component.Schema.Title.Equals("XSLT Test - Ignor")) 

However might I mention that is still a bit of a risky comparison, it is better if you use a TCMURI or WebDAV URL to check the Schema, which you get from a configuration.

If you take a look at the example event system I wrote a long time ago, then you can see there how you can get such values from metadata of an organizational item (like a Folder or a Publication). The event system source code is downloadable for free on https://www.sdltridionworld.com/community/2011_extensions/rapideditorialinterface.aspx

For more information on how to debug an event handler (it's basically standard Visual Studio stuff), take a look here http://yatb.mitza.net/2012/03/debugging-tridion-2011-event-system.html

  • Hi Bart, I am facing the same issue for if (component.Schema.Title.Equals("XSLT Test - Ignor")) . – Sayantan Basu May 19 '15 at 9:49
  • Can you please suggest how I can debug it from remote machine or I can put the log from code to event viewer. – Sayantan Basu May 19 '15 at 9:51
  • @SayantanBasu Did you look at the example code I suggested? That has logging in there using the Tridion.Logging.DLL, but you can also use something like Log4Net. – Bart Koopman May 19 '15 at 11:58
  • Hi Bart, Thanks for the help. I am able to write the log from my code now. And the issue is resolved. – Sayantan Basu May 19 '15 at 16:11

This might be your problem:

component.Schema.Equals("XSLT Test - Ignor")

component.Schema won't give you the title of the Schema.

It might help you in the future to put some logging in your events code, so that you can see if it goes to the else clause. And of course, you should know how to attach a debugger.

  • component.Schema.Title.Equals("XSLT Test - Ignor") - Is it work properly ? – Sayantan Basu May 19 '15 at 9:03
  • Hi Dominic, Can you please let me know how I can debug my event system code from remote machine. – Sayantan Basu May 19 '15 at 9:06
  • Thnaks Dominic the issue is resolved now.. – Sayantan Basu May 19 '15 at 16:11

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.