How to know what fields has changed on the BO when the saved


Author
Message
Jeff Pagley
Jeff Pagley
Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Hi SF,

My client has asked me to send an email alert when a value has changed in a field for a record.  Is there an event the BO fires that I can handle which tells me what fields has changed and the before and after values of those fields?

Or does anyone have any suggestions on how I can do this?

Thanks,

Jeff

Using C#/Visual Studio 2008
Replies
Sam Tenney
Sam Tenney
StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)StrataFrame User (140 reputation)
Group: StrataFrame Users
Posts: 70, Visits: 3.5K
I am a beginner and I must be missing something simple.

In the BeforeSave method of my BO, I want to compare the current value of a field to the original value.  I am using C# and Visual Studio 2008 and when I try to enter:

If (!BO.CurrentRow.Item(colCount, Data.DataRowVersion.Original) == BO.CurrentRow.Item(colCount, Data.DataRowVersion.Current))

it appears that BO.CurrentRow does not have a method named Item.  What am I doing wrong?

Sam Tenney
Jeff Pagley
Jeff Pagley
Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
I have been testing this code in the BO_BeforeSave event and it seems to work:



// Established a local for the BO's current row

DataRow dataRow = this.CurrentRow;

// Iterate through the columns of the data table

foreach (DataColumn item in this.CurrentDataTable.Columns)

{

// Determine what data row column to retrieve it's value

if (item.ColumnName.Equals("cc_Description") || item.ColumnName.Equals("coco_Description"))

{

// Compare the original version with the current to determine if it changed

if (dataRow[item.ColumnName, DataRowVersion.Original] != dataRow[item.ColumnName, DataRowVersion.Current])

{

Console.WriteLine(String.Format("Table: {0}", this.TableName));

Console.WriteLine(String.Format("Col ({0}) Original = {1} Current = {2}", item.ColumnName, dataRow[item.ColumnName, DataRowVersion.Original].ToString(), dataRow[item.ColumnName, DataRowVersion.Current].ToString()));

}

}

}



I hope this is helpful.

Jeff
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search