I have implemented the following:
Added a new fields on the sales order header call Max Amount and Max Amount Threshold.
The problem I am having is the user should get a warning if the blanker order lines exceed the Max amount. and Alse the user gets a warning when billing more that the Max Amount * Max Amount Threshold.
How can I do this with code?
I have created a function and has the below code:
Is this on the right track? Am i missing something?
Totalfields is a variable in the function.
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","No.");
//SalesLine.TotalFields(SalesLine.Amount);
TotalFields := TotalFields + SalesLine.Amount;
IF("Max Amount" * "Max Amount Threshold") > SalesLine.Amount THEN
MESSAGE(Text052, "Max Amount",SalesLine.Amount);
Comments
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","No.");
//SalesLine.TotalFields(SalesLine.Amount);
if SalesLine.FIND('-') THEN repeat
TotalFields := TotalFields + SalesLine.Amount;
until SalesLine.next = 0;
IF TotalFields > ("Max Amount") THEN
MESSAGE('Amount cannot be more than %1', "MaxAmount");
//IF("Max Amount" * "Max Amount Threshold") > SalesLine.Amount THEN
// MESSAGE(Text052, "Max Amount",SalesLine.Amount
IF("Max Amount") > SalesLine.Amount THEN
MESSAGE(Text052, "Max Amount",SalesLine.Amount);
IF("Max Amount" * "Max Amount Threshold") > TotalFields THEN
MESSAGE(Text052, "Max Amount" *"Max Amount Threshold",TotalFields);
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","No.");
if SalesLine.FIND('-') THEN repeat
IF SalesLine.Amount > ("Max Amount") THEN
MESSAGE('Amount cannot be more than %1 in Line No.
%2', "MaxAmount",SalesLine."Line No.");
TotalFields := TotalFields + SalesLine.Amount;
until SalesLine.next = 0;
IF TotalFields > ("Max Amount" * "Max Amount Threshold") THEN
MESSAGE('Total billing Amount cannot be more than %1',
"Max Amount" * "Max Amount Threshold");
For CheckThresholdValue function, the Parameters are set to pass by reference.
Am I calling the function in the correct place for line amount in the sales line table? Where should i call the function from?