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.
*This post is locked for comments
If you would like to run the program by click of the button then you should write the code on Action trigger.
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.
Hello Lewishhh,
Call this function in button-onvalidate trigger.
So whenever button clicked trigger fired, and based your logic your code will execute...
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
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
Sohail Ahmed
2
mmv
2
Amol Salvi
2