Custom Table Event Handler

Yang Wen asked on September 29, 2016 00:50

I've created event handlers on my custom table for the Update.Before and Update.After event types.

I need to compute a delta for the data update, so I need snapshots of the data before & after the update.

In the Update.Before event handler, the ObjectEventArgs object doesn't seem to contain the data that will be written to the DB. I see properties for standard fields like ItemGUID, ItemID, ItemModifiedWhen, etc. However none of my custom fields on the table are obviously accessible. Is there a method I need to call to retrieve values for a specific column (Keep in mind this is Before Update, so data has not been persisted into the DB yet).

Any help is appreciated.

Correct Answer

Brenden Kehren answered on September 29, 2016 04:49

With a before you can get both old and new values. Simply use something like:

string updatedValue = ValidationHelper.GetString(e.Object.GetValue("ColumnName"), ""); string originalValue = ValidationHelper.GetString(e.Object.GetOriginalValue("ColumnName"), "");

No need to use the UpdateAfter event handler if you're just looking to get those values.

4 votesVote for this answer Unmark Correct answer

Recent Answers


Yang Wen answered on September 29, 2016 20:03

thanks!

0 votesVote for this answer Mark as a Correct answer

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