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)

Buttons

(0) ShareShare
ReportReport
Posted on by

How can I correct this so this function only occurs when a button is pressed. If the QA Inspection IN button is ticked it should post the comment I've created below. If it hasn't been ticked nothing should happen. 

Here is the code.

57.PNG

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rabin Profile Picture
    2,976 on at

    Hi Try this...

    Try using INIT Function, its initializes the Record where you can INSERT the Values later...

    [CODE]

    --------

    IF recVendor."QA Inspection IN" = TRUE then BEGIN

    // No need of Making the QA Inspection IN True again...

    recVendorCommentline.Reset;

    recVendorCommentLine.SETRANGE("Table Name",recVendorCommentline."Table Name"::Vendor);

    recVendorCommentline.SETRANGE("No.",recVendor."No.");

    if recVendorCommentLine.FINDLAST THEN

    intLineNumber := recVendorCommentline."Line No."+ 10000;

    Else

    intLineNumber := 10000;

    //CLEAR(recVendorCommentline);

    recVendorCommentline.INIT; // Initialize a record line | Blank Line  <=================

    recVendorCommentline.validate("No.",recVendor."No.");

    recVendor....Similarly.

    recVendorCommentline.INSERT; // <=================

    END

  • Suggested answer
    HILBE Profile Picture
    300 on at

    Hi Lewishhh,

    you have forgotten a line in your code:

    After

    CLEAR(recVendorCommentLine);

    you should insert:

    recVendorCommentLine."Line No." := intLineNumber ;

    This should make the code working.

    best regards

    Robert

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hello Lewishhh,

    Call this function in button-onvalidate trigger.

    So whenever button clicked trigger fired, and based your logic your code will execute...

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    There are two issues in the code

    1. Why are you using assingning QA Inpsection IN :=  TRUE when you arleady executing the code when it is TRUE

    2. You are assigning the Line No. when you are creating the Comment Line.

    I believe QA Inspection IN is a boolean on the Vendor card and you want to execute the above function when it is true, so just add the code on the OnValidation of that field and your above code should work fine.

    Let us know any other issue you are facing.

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    If you would like to run the program by click of the button then you should write the code on Action trigger.

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)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans