StrataFrame Forum

Business Rules question...

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

By StarkMike - 9/20/2006

When creating business rules is there a way to specify that certain rules will only be enforced if the record in question is a new one and not just editing an existing one?



For example I want to do a check to make sure that the PO number isnt already in the system.. but that would only apply to adding new purchase orders and not editing existing ones.
By Trent L. Taylor - 9/20/2006

When creating business rules is there a way to specify that certain rules will only be enforced if the record in question is a new one and not just editing an existing one?

Yes.  You will need to look at the RowState of the row.  It will look something like this:

If MyBO.CurrentDataTable(MyBo.CurrentRowIndex).RowState = Added Then
   '-- Put your test
End If

By StarkMike - 9/20/2006

Where do I do that at? In the BO or in the form?

I tried to add that code to CheckRulesOnCurrentRow in the BO and it didnt work.

By Steve L. Taylor - 9/20/2006

Mike,

Yes place the following code in the BO and it should work.

 If Me.CurrentRow.RowState = DataRowState.Added Then
     '-- do your thing 
 End If  

Steve