Validating Child object based on Parent

Validating Child object based on Parent

Old forum URL: forums.lhotka.net/forums/t/7619.aspx


cash_pat posted on Monday, September 14, 2009

Hi all,

How do i validate a child object based on its parent object's property.

   If Me.Parent.VoucherType = VoucherTypesEnum.Purchase Then

           ValidationRules.AddRule(AddressOf CommonRules.StringRequired, New RuleArgs(CompanyVoucherNoProperty), 0)
        
     End If

But the parent property has a value of nothing when the object is created.

Any ideas.


thanks

Cash pat
  

JonnyBee replied on Monday, September 14, 2009

Hi,

I would suggest that you write your own custom rule and within the body of the rule you check the parent.VoucherType and determine whether field is required or not.

/jonnybee

Copyright (c) Marimer LLC