Skip to main content

Notifications

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

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

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

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: Buttons

    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
    Binesh Profile Picture
    7,885 on at
    RE: Buttons

    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
    HILBE Profile Picture
    300 on at
    RE: Buttons

    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

  • Verified answer
    Rabin Profile Picture
    2,976 on at
    RE: Buttons

    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

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans