StrataFrame Forum

BO Error Validation

http://forum.strataframe.net/Topic25061.aspx

By Ross L. Rooker, Sr. - 10/29/2009

I have a BO that has logic to automatically display broken rules. On the form, in the BO BeforeSave event the code automatically populates several columns and then I need to fire off the check rules on the BO. It appears as though the BO check rules is being fired before the "BeforeSave" event of the BO on the form. Is my assumption correct? If so, how can I check the rules in the BeforeSave event and if an error cancel the SAVE and display the error? Also, this only occurs when I am adding a NEW row to the table. When editing an existing row, the broken rule displays.
By Trent L. Taylor - 10/29/2009

Is my assumption correct?

Yes.

If so, how can I check the rules in the BeforeSave event and if an error cancel the SAVE and display the error?

You will want to handle the BusinessRulesChecked event as this will give you what you need and allow you to even force a save if you so choose.

By Ross L. Rooker, Sr. - 10/30/2009

Thanks. It is helpful to know that by the time the BeforeSave occurs on the BO, that the Broken Rules have already been checked. I just added my default logic into the BO CheckRulesOnCurrentRowto run ahead of the of the code that generates the AddBrokenRule.

I would have put this logic into the SetDefaultValues except, I do cannot run that logic until the user fully fills out the form, then when they click on SAVE I can then run my default logic which then lets me know if certain rules required the user to enter other information.