locked
Force OnValidate event to fire. RRS feed

  • Question

  • User924607044 posted

    Hi,

     I've got the following scenario:

    Parent table Order which is linked to multiple child OrderLines.

    The Order table implements a rule, via OnValidate, that checks that the contents of the OrderLines table meets certain criteria.

    I have exposed this via Dynamic Data using an inline grid to generate the UI for this.

    The problem is this:

    The OnValidate event of the Order object does not fire when I add or remove items from the OrderLines collection because the Order object has not technically been modified.

    Is there a way to 'Invalidate' the Order object so that OnValidate fires regardless of whether it has been physically modified or not?

    Regards

    Nick

    Monday, September 22, 2008 7:47 AM

Answers

  • User-330204900 posted

    Why don't you just create a single method that can be called from either the Order or OrderLine's OnValidate and then do your validation there?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 22, 2008 9:32 AM

All replies

  • User-330204900 posted

    Why don't you just create a single method that can be called from either the Order or OrderLine's OnValidate and then do your validation there?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 22, 2008 9:32 AM
  • User924607044 posted

    Why don't you just create a single method that can be called from either the Order or OrderLine's OnValidate and then do your validation there?

    Hi Steve,

    This will work fine. What was causing the confusion is that a Single Order Line does not have enough state to understand how to implement the rules. What I've done is call this.Order.ValidateOrderLines from the OrderLine OnValidate.

    Thanks

     Nick

    Monday, September 22, 2008 9:41 AM