I have created a sample event system code to update a field of a Component when it is using a particular Schema.
DLL created and deployed properly
Added the assemblyFileName in to the config as well
Source code of the event system:
namespace com.jio.events.ComponentEventHandler
{
[TcmExtension("ComponentEventHandlerEventSystemExtension")]
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();
component.Save();
component.CheckIn();
}
else
{
return;
}
}
}
}