Nav 2013 - Validate a record for fields

kjboloekjboloe Member Posts: 56
edited 2013-01-16 in NAV Three Tier
Hi

I would like to validate that some fields is modified when the user want to update the record.

I have made corrections in the OnModify for table Job Journal Line.

TESTFIELD(Description);

When I try to insert a new record in the Job Journal and I don't update the field, I get an error that Description must be entered, when I then try to modify the field, I get an error that the uniq keys is wrong. I seens like it has thrown the connection to the record, when I trow an error.

I have tried to move the code to the page trigger, but without any result ](*,) .

Hope that someone can help me :-)
Kind regards

Kenneth Jarlshøi Bolø
Dynateam A/S

Comments

  • kjboloekjboloe Member Posts: 56
    Hi, the error I get is this in danish :

    Feltet kan ikke valideres, fordi nøglefelter er ugyldige. :?

    Best Regards,
    Kenneth
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
  • kjboloekjboloe Member Posts: 56
    Hi, I have tried to change the code in a standard.

    In Table 210, in the OnModify trigger :

    OnModify()
    IF (Type = Type::Item) AND (xRec.Type = Type::Item) THEN
    ReserveJobJnlLine.VerifyChange(Rec,xRec)
    ELSE
    IF (Type <> Type::Item) AND (xRec.Type = Type::Item) THEN
    ReserveJobJnlLine.DeleteLine(xRec);

    // This is my code :
    TESTFIELD(Description);

    When I insert a record without a description, I get an error :

    "Description must have a value in Job Journal Line: Journal Template Name = SAGER, Journal Batch Name=STANDARD, Line No.=190000. It cannot be zero or empty."

    Then I update the field, but I can't do that ](*,)
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
  • kjboloekjboloe Member Posts: 56
    If I try to delete the record I get this error :

    "Delete cannot be performed since it has a key error."

    Please help, I think that I have to contact Microsoft. :roll:
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
  • Johannes_NielsenJohannes_Nielsen Member Posts: 206
    kjboloe wrote:
    Hi, I have tried to change the code in a standard.

    In Table 210, in the OnModify trigger :

    OnModify()
    IF (Type = Type::Item) AND (xRec.Type = Type::Item) THEN
    ReserveJobJnlLine.VerifyChange(Rec,xRec)
    ELSE
    IF (Type <> Type::Item) AND (xRec.Type = Type::Item) THEN
    ReserveJobJnlLine.DeleteLine(xRec);

    // This is my code :
    TESTFIELD(Description);

    When I insert a record without a description, I get an error :

    "Description must have a value in Job Journal Line: Journal Template Name = SAGER, Journal Batch Name=STANDARD, Line No.=190000. It cannot be zero or empty."

    Then I update the field, but I can't do that ](*,)

    The error states that Description value is missing...
    When you dont provide TESTFIELD with the second argument, then the value is checked for not being empty.
    http://msdn.microsoft.com/en-us/library/dd301274.aspx

    But consider stepping back from what you're doing, and do some studying and training before proceding further.
    As a partner you have access to all the training material, even instuctor material on partnersource :thumbsup:
    Best regards / Venlig hilsen
    Johannes Sebastian
    MB7-840,MB7-841
  • kjboloekjboloe Member Posts: 56
    Hi, I if fill the field with a value, I don't get any errors.

    If have tried to change the code to :

    IF Description = '' then
    error('Description must be entered');

    But with same result.

    The problem is not the check, but the possibility to change the data after the error.
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
Sign In or Register to comment.