StrataFrame Forum

Infobox not showing for a related BO broken rule

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

By Edhy Rijo - 11/12/2007

Hi,

I have a Mainteanance Form with two Business Objects, a parent and a child on the same form.  When trying to save a parent record the broken rule functionality shows the red arrow and infobox properly, but when doing the same thing with a child record, only the red arrow is shown and not the infobox.

Is there something I need to do in order to get the infobox to show for the child BO when a broken rule validation is triggered?.

Please see both images to see what I meant....

Thanks!

By Trent L. Taylor - 11/13/2007

More than likely you are not calling the Save() method on the form but rather on the BOs individually.  The InfoBox will not appear when the Save() on the BO alone is called.  You can call the CheckRules on the BO (which it might display them, I cannot remember off of the top of my head) or just make the call to Save() of the form which will force this logic.
By Edhy Rijo - 11/13/2007

Trent L. Taylor (11/13/2007)
More than likely you are not calling the Save() method on the form but rather on the BOs individually.  The InfoBox will not appear when the Save() on the BO alone is called.  You can call the CheckRules on the BO (which it might display them, I cannot remember off of the top of my head) or just make the call to Save() of the form which will force this logic.

Hi Trent,

Yes, you are right, I am calling the BO.Save() because I want to control the saving of parent and child separate, so I had the form's property IncludeInFormSaveType = AllBusinessObject, when I originally had the value PrimaryBusinessObject in order to avoid the main toolstrip menu to react when a child BO was changed. 

Now using IncludeInFormSaveType = AllBusinessObject shows the InfoBox when there is a broken rule on the child BO, but it shows the wrong numbers of broken rules, see picture attached.

The help file does not says anything about all SF properties and methods, so it is a bit hard for a newbie like me to figure things out Wink but I will rather keep the BO states separate from the Primary BO, so the question would be... Is there another way to show the InfoBox when there is a broken rule in any BO?

I don't know why it i s done this way, but I believe the functionally of the InfoBox and the Broken rules should work the same for any BO and not just from the form's save method.

Here is the code I originally had in the form and would like to keep:

If Me.ServiceCallsAppliancesBO1.CheckRules(True) Then

     '-- Save the child record and set the focus back to the listview.

     Me.ServiceCallsAppliancesBO1.Save()

     Me.lvAppliances.Focus()

End If

By StrataFrame Team - 11/19/2007

When you call the CheckRules() method, it checks the rules on all of the business objects, so, if there are broken rules on child business objects, it adds the counts together from all of the business objects (that's why you're getting a 2).  So, I would recommend leaving the code like you had it (where the InfoBox won't pop up on its own) and instead, add a handler to your primary business object's BusinessRulesChecked event on the form.  In that event handler, if the event args says the count of broken rules is greater than 0, then show an InfoBox with the message that you want to show.