Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business rule against a form property
Message
From
08/12/2001 18:41:55
 
 
To
06/12/2001 20:27:22
Gil Munk
The Scarborough Group, Inc.
Baltimore, Maryland, United States
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00590665
Message ID:
00591734
Views:
27
>>Hope this isn't another dumb question but ....
>>
>>I have a business rule object that has a rule which simply compares the sum of several fields in the view with a total that the user entered in the form (the tot is saved in a property on the form).
>>
>>I tried something like:
>>
>>if v_invoice.ext + v_invoice.tax + v_invoice.extras <> thisform.nTotal
>>
>>which blew up because there is no form in the business rule class! So I'm using _screen.activeform.nTotal instead. Is this the best way to reference the property?
>>
>>Thanks
>
>Sally,
>
>Agreeing with Michael and Jay, it's good practice not to reference a form from within a business object unless you wrap it in a method that determines if the BO is being hosted by a form. The kBizObz has just such a method: IsFormHost().
------------------------------

Thanks Michael, Jay, and Gil. What I did was to put this code in the business rules object checkrules():

IF this.obizobj.isFormHost() && is this business object on a form?
this.doestotaladdup()
endif

The code in doestotaladdup() is:

LOCAL lcRule
lcRule = "Totals don't add up"
IF v_invoice.ext + v_invoice.tax + v_invoice.extras <> screen.activeform.nTotal
This.Addbrokenrule(lcRule)
ELSE
This.clearbrokenrule(lcRule)
ENDIF

Sound good? Is there a property or easy way to get the form's name?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform