Checking what changed in an event

John Sharp asked on November 15, 2017 12:09

In an Insert or Update event is there a way to understand what field has changed? I'm trying to isolate a function to only being called when a particular field has been changed but I'm not sure how to check the before and after versions of the object.


OrderInfo.TYPEINFO.Events.Update.After += InsertOrUpdate_After;

private void InsertOrUpdate_After(object sender, ObjectEventArgs e) { OrderInfo order = e.Object as OrderInfo; if (FieldChanged(order, OrderStatusID)) { // do my action; } }

Many thanks,


Recent Answers

Brenden Kehren answered on November 15, 2017 14:35

In your global event handler you can check the new value and original values using this:

var currentValue = e.Object.GetValue("ColumnName");
var originalValue = e.Object.GetOriginalValue("ColumnName");
0 votesVote for this answer Mark as a Correct answer

John Sharp answered on November 16, 2017 12:21

Thanks Brenden, I've added the code in and will send some vote happiness your way when I've had a chance to test.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.