Field Validation

shibilyshibily Member Posts: 89
Hi all.
I want to validate some fields (whether it is blank or not) . If it is blank i want a alert message indicating the same. I have more than one fields to validate . It should happen when i am trying to close the screen becuase it is a bounded form.
After getting the message the screen should be intact and focus to the relevant field.

I tried it with ERROR function. The message comes and when i click OK the screen closes. That should not happen

How it can be possible

Thanks in advance
Shibily

Answers

  • DaveTDaveT Member Posts: 1,039
    Hi
    Have you looked ar the testfield function ?
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • shibilyshibily Member Posts: 89
    DaveT wrote:
    Hi
    Have you looked ar the testfield function ?

    Thanks Dave
    But in which event should i use this. ( i tried in On Close Form) and the message comes. But when i click OK the screen got closed
  • DaveTDaveT Member Posts: 1,039
    Hi

    The Onclose trigger is too late - try in the Onquerycloseform - this is meant for tests to see if the form can be closed. :wink:
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • jonsan21jonsan21 Member Posts: 118
    Try this:

    Change the DelayedInsert property of the form to yes. Create validation functions in the OnInsert trigger.
    Rgds,

    Jon.
  • shibilyshibily Member Posts: 89
    Thanks. It is working fine. Any idea how to set the focus to the specified field after clicking OK in message Box.??
  • JoeriJoeri Member Posts: 75
    If you want to run some code that sets the focus to a specific control you can't use error of testfield because it stops all processing.

    What you have to do is create on the OnQueryCloseForm trigger some code that first validates a field and secondly sets the focus to a field that isn't validated. For example:
    IF <Rec.Field> = '' THEN BEGIN
      MESSAGE("%1 is empty",<Rec.Field>); //Doesn't stop the processing
      CurrForm.<Control>.ACTIVATE; //Sets the focues on the control
      EXIT(FALSE); //Keeps from exiting the form
    END;
    
Sign In or Register to comment.