Options

Check field entry

frederic.wfrederic.w Member Posts: 11
Hello,

I would like to check that for example the fields "Item Category Code" and "Location Code" are not empty when going to the next record or living the item form.
With this kind of check I would like to tell the user he has forgotten to enter important information's. Of course if he enters anything the check did not help, but at least he was informed.

Is there a easy way to do that kind of check?

Thanks for your help,

Frederic

Comments

  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    Form - OnQueryCloseForm() : Boolean
    EXIT(CheckMandatoryFields);

    Form - OnNextRecord(Steps : Integer) : Integer
    IF NOT CheckMandatoryFields THEN
    EXIT(0);

    CheckMandatoryFields() : Boolean
    EXIT(("Item Category Code" <> '') AND ("Location Code" <> ''));
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    UrmasUrmas Member Posts: 76
    It depends how experienced you are.
    I am here using the solution where the default value for "Blocked" is always Yes and while validating the Blocked field (if new value is Blocked=No), system checks against the fields what have to be filled (simple TESTFIELD commands).
  • Options
    frederic.wfrederic.w Member Posts: 11
    Well, I'm very new with Navision and don't have much experience!

    Where do I have do declare the "CheckMandatoryFields(): Boolean"?

    Is it possible to tell the user witch fields needs do bee field up?
  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    frederic.w wrote:
    [...]
    Where do I have do declare the "CheckMandatoryFields(): Boolean"?
    [...]
    In the form where you want to check the mandatory fields, you have to select "View -> Globals" and go to the tab "functions".
    frederic.w wrote:
    [...]
    Is it possible to tell the user witch fields needs do bee field up?
    Yes, it is, simply expand the statement
    EXIT(("Item Category Code" <> '') AND ("Location Code" <> ''));
    with the fields to be checked:
    EXIT(("Item Category Code" <> '') AND ("Location Code" <> '') AND (MyCodeField <> '') AND (MyBoolean <> FALSE) AND (MyDecimal <> 0));
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    frederic.wfrederic.w Member Posts: 11
    Hello Timo,

    as soon I put the value:

    Form - OnNextRecord(Steps : Integer) : Integer
    IF NOT CheckMandatoryFields THEN
    EXIT(0);

    I can't step from one record to an other with the icon "Next" , "Previous" or "PpUp" , "PgDn" even if all fields are filled up.
  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    Please post your CheckMandatoryFields() code here so I can have a look.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    frederic.wfrederic.w Member Posts: 11
    I tried to use exactly the code from your example:

    Form - OnQueryCloseForm() : Boolean
    EXIT(CheckMandatoryFields);

    Form - OnNextRecord(Steps : Integer) : Integer
    IF NOT CheckMandatoryFields THEN
    EXIT(0);

    CheckMandatoryFields() : Boolean
    EXIT(("Item Category Code" <> '') AND ("Location Code" <> ''));
  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    I have no idea at this time.
    Could you check it with the debugger?
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    UrmasUrmas Member Posts: 76
    There is small error in the code you supplied.

    You leave the exit result uninitialized (and therefore = 0) in OnNextRecord if the added function returnes TRUE.

    The correct trigger for OnNextRecord(Steps : Integer) : Integer would be


    OnNextRecord(Steps : Integer) : Integer
    IF NOT CheckMandatoryFields THEN
    EXIT(0)
    ELSE
    EXIT(Steps);
  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    ](*,) #-o :whistle:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    frederic.wfrederic.w Member Posts: 11
    I'm soory, as soon as I put the value:

    OnNextRecord(Steps : Integer) : Integer
    IF NOT CheckMandatoryFields THEN
    EXIT(0)
    ELSE
    EXIT(Steps);

    I can not step anymore in the form from one record to an other with the icon "Next" , "Previous" or "PpUp" , "PgDn" even if all fields are filled up.

    Is there a solution?
  • Options
    fbfb Member Posts: 246
    The code should be:
    IF NOT CheckMandatoryFields THEN 
      EXIT(0) 
    ELSE 
      EXIT(NEXT(Steps));
    
  • Options
    UrmasUrmas Member Posts: 76
    ](*,) :-# :wink:
    I forgot the actual intended behavour of the trigger.
  • Options
    frederic.wfrederic.w Member Posts: 11
    The problem with the stepping through the records is ok.

    When the checked field is empty , I would like to have a message "Enter Category Code" when stepping to a next record. The program should stay on the actual record and not show an empty new record. How can I program this?

    Thank you for your help and patience!
  • Options
    frederic.wfrederic.w Member Posts: 11
    No solution??
Sign In or Register to comment.