Project Automation Item Events allow you to intercept before and after an operation during the sync process.
You can cancel an operation by setting the Sync property to false in the Before event this is the same as unchecking the Sync flag in the comapre results window except this allows you to do it programatically.
Note: Not all Data Connectors support Item Events
The item field contains details about the item to be either Added, Updated or Deleted.
The identity field may contain the ID value of the target item this depends on the provider implementation.
One use-case is where you want to update the source system with the created ID value from the target, for example where in Dynamics CRM you want to add the Entity Guid to your source SQL Table whenever a new account is added. This can be done easily via the UpdateSourceRow helper function on the SQL Data Connector.
public override void AfterAddItem(object sender, DataCompareItemInvariant item, object identity)
{
DataSourceA.UpdateSourceRow("CRM_ID", identity, item);
}
Another Example is using this to clear a Sync flag on the source SQL Table after it has been written to the target.
public override void AfterAddItem(object sender, DataCompareItemInvariant item, object identity)
{
DataSourceA.ExecuteNonQuery(string.Format("UPDATE {0} SET [Sync]=0 WHERE [ID]=?", DataSourceA.SourceTable), item.Key);
}