web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Validation Not Working

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  I have below code but it is not working. It is written in Sub Form

Account No - OnValidate()
IF "Account No" = '' THEN
ERROR(Txt0003);

On Push in Main Form below is the code . CNLine1,CNLine refers to sub form SourceTable

CNLine1.VALIDATE("Account No",  CNLine."Account No");

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    CDsilva Profile Picture
    4,188 on at

    Use session debugging, looks like Account No is fetched as blank.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    What do you mean by "not working"? It throws an error or it doesn't trow the validation?

    If the error returned is the message in Txt0003 then you're passing a blank value (this is what your code is doing).

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     It does not throw any error

    Thanks

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     When Debug  it shows

       CDNLine1.VALIDATE("Account No",  CDNLine."Account No");

    = error "Validate("Account No " , CDNLine was not found);

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    If it doesn not throw any error is because you're passing a non empty value.

    You have written:

    CNLine1.VALIDATE("Account No",  CNLine."Account No");

    it seems that CNLine."Account No" is not empty (in the OnValidate trigger you throw an error ONLY if "Account No." is empty).

  • Suggested answer
    CDsilva Profile Picture
    4,188 on at

    Hi,

    Check the property of account no for table relation etc

  • jsshivalik Profile Picture
    3,099 on at

    Hi

    In Table it is undefined

    Validate  Table Relation = Yes

    Thanks

  • Suggested answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi jsshivalik,

    It seems that you want to make "Account No" should not be left blank.

    You can use TESTFIELD("Account No") in OnInsert() trigger of the table.

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     Below is the code . CDNLine,CDNLine1 refers to same table.

    CDNLine.SETRANGE("Location","No.");

    CDNLine.SETFILTER("DAmount",'>%1',0);

    IF CDNLine.FINDFIRST THEN BEGIN

     REPEAT

       EntryNo := EntryNo + 1;

       CDNLine1.VALIDATE("Location", "No.");

       CDNLine1.VALIDATE("Entry No", EntryNo);

       CDNLine1.VALIDATE("Posted Date",  CDNLine."DDate");

       CDNLine1.VALIDATE("Posted Amount",  CDNLine."DAmount");

       CDNLine1.VALIDATE("Account No",  CDNLine."Account No");

       CDNLine1.INSERT;

     UNTIL CDNLine.NEXT = 0;

    END;

    Thanks

  • jsshivalik Profile Picture
    3,099 on at

    Hi  Chris

     When i write below code then it works but i want if error on Testfield then i want to display my own Error message

       CDNLine.TESTFIELD("AccountNo");

       CDNLine1.VALIDATE("AccountNo",  CDNLine."AccountNo");

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans