Validate Filed

AlkroAlkro Member Posts: 115
Merry Christmas!!

I have one List Form and i want that when user puts a value in one field, Validate of this field in the table will not be execute. Only must be executed OnValidate of this field in the Form, not in table.

Is Possible?

Comments

  • lvanvugtlvanvugt Member Posts: 774
    edited 2009-12-30
    Why should you want to do this? OnValidate code on field level is to 'enforce' business logic for that specific field.

    Nevertheless, as far as I know this is not possible (complying to standard NAV programming practice).

    Raed more on validating date on my blog posts http://dynamicsuser.net/blogs/vanvugt/archive/2009/12/19/validating-data-user-input.aspx and http://dynamicsuser.net/blogs/vanvugt/archive/2009/12/19/validating-data-calling-validate.aspx.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Cem_KaraerCem_Karaer Member Posts: 281
    There is no simple way to solve it. Here is the workaround:
    1. Create single instance codeunit
    2. Create boolean variable in the CU
    3. Create two functions in the CU, one for setting and the other for getting the boolean variable
    4. Declare CU in the table and form
    5. In the OnOpenForm trigger of the form, set the CU's boolean to TRUE
    6. In the OnValidate trigger of the table get the boolean value of CU. Run the code of the OnValidate trigger if the boolean value is FALSE don't run if it is TRUE
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
  • kapamaroukapamarou Member Posts: 1,152
    cemkaraer wrote:
    There is no simple way to solve it. Here is the workaround:
    1. Create single instance codeunit
    2. Create boolean variable in the CU
    3. Create two functions in the CU, one for setting and the other for getting the boolean variable
    4. Declare CU in the table and form
    5. In the OnOpenForm trigger of the form, set the CU's boolean to TRUE
    6. In the OnValidate trigger of the table get the boolean value of CU. Run the code of the OnValidate trigger if the boolean value is FALSE don't run if it is TRUE

    What about creating a variable that is of the same type as the field.
    Then show this specific variable on the form and add code on that control instead of the table field. Handle the value (load / save from the record) and don't call the table validation. :-k

    This could be an easy way.

    But I strongly suggest you avoid this. Validation should be called. You must really really know the impacts of something like this. :-#
  • Cem_KaraerCem_Karaer Member Posts: 281
    7. Don't forget to set boolean to FALSE in the OnCloseForm trigger.
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
Sign In or Register to comment.