Hi Franz,
I have one question on sales order page , as we have sale lines in that I have added net weight field and extended weight custom field. My question is that how I can get quantity * Net weight value into extended weight field? Can we do multiply any operation for sales lines????
Thank You
you're welcome.
interesting. the code worked for me without currpage.update.
please set one of my answers to verified.
it's working.
modify(Quantity)
{
trigger OnAfterValidate()
begin
UpdateTotalQty();
currPage.Update();
end;
}
It was not updationg the page on modify event. When I added CurrPage.Update(); Then It started working.
Thank you so much for your help.
use trigger OnAfterValidate instead of OnBeforeValidate.
Hi Franz Kalchmair,
I really appreciate your help. I copy and paste your code and publish it. But still I am not getting the require result. You can see below attachment.
When I modify quantity 3 to 6 and then I clicked in the qty to assemble to order field in the same row. It did not updated. However, When I click on below or above any field then it's works.
that works:
pageextension 50104 SalesOrderSubformExt extends "Sales Order Subform"
{
layout
{
addlast(Control51)
{
field(TotalQty; TotalQty)
{
Caption = 'Total Qty';
Editable = false;
ApplicationArea = all;
}
}
modify(Quantity)
{
trigger OnAfterValidate()
begin
UpdateTotalQty();
end;
}
modify("Unit Price")
{
trigger OnAfterValidate()
begin
UpdateTotalQty();
end;
}
}
procedure UpdateTotalQty()
var
salesLine: record "Sales Line";
begin
salesLine.CopyFilters(Rec);
salesLine.CalcSums(Quantity);
TotalQty := salesLine.Quantity;
end;
trigger OnAfterGetCurrRecord()
begin
UpdateTotalQty();
end;
var
TotalQty: Decimal;
}
I have tried below procedure as you said but not working.
pageextension 50102 SalesOrderLinesPage extends "Sales Order Subform"
{
layout
{
modify(Quantity)
{
trigger OnBeforeValidate()
begin
UpdateTotalQty();
end;
}
addlast(Control45)
{
group("")
{
field("Sum of Quantity"; TotalQty)
{
ApplicationArea = all;
Caption = 'Total Quantityy';
Editable = false;
}
field("Total # Medical Skids"; "Total # Medical Skids")
{
ApplicationArea = all;
Caption = 'Total # Medical Skids';
}
}
}
addlast(Control28)
{
field("Sum of Weight"; TotalWght)
{
ApplicationArea = all;
Caption = 'Total Weight(LBS)';
}
field("Total # Supply Skids"; "Total # Supply Skids")
{
ApplicationArea = all;
Caption = 'Total # Supply Skids';
}
}
}
procedure UpdateTotalQty();
begin
SalesLine.CopyFilters(rec);
SalesLine.CalcSums(Quantity);
TotalQty := SalesLine.Quantity;
SalesLine.CalcSums("Gross Weight");
TotalWght := SalesLine."Gross Weight";
end;
trigger OnAfterGetCurrRecord()
begin
SalesLine.CopyFilters(rec);
SalesLine.CalcSums(Quantity);
TotalQty := SalesLine.Quantity;
SalesLine.CalcSums("Gross Weight");
TotalWght := SalesLine."Gross Weight";
end;
var
TotalQty: Decimal;
SalesLine: record "Sales Line";
TotalWght: Decimal;
}
like in the standard code it's needed that the new field is also updated whenever the main fields unit price, quantity, etc are changed, the update code for totalqty is run. then totalqty is also updated when you leave the field within the line.
so instead of
trigger OnAfterGetCurrRecord()
begin
SalesLine.CopyFilters(Rec);
SalesLine.CalcSums(Quantity);
TotalQty := SalesLine.Quantity;
end;
var
TotalQty: Decimal;
SalesLine: record "Sales Line";
create a procedure UpdateTotalQty with the above code.
run that update code in the onvalidate trigger of the sales line fields, which you want them to update the new field.
e.g.
...
layout
{
...
modify("Unit Price")
{
trigger OnAfterValidate()
begin
UpdateTotalQty();
end;
}
}
Yes, I forgot to add Application area=all;
It's working. But when I modify the quantity or adding new line it's not updation same time until I click on next line. Why someone will click on next line?....
Like Total Excl. Tax(CAD) and some other fields change on the same time as we enter price.
Yes, I forgot to add Application area=all;
It's working. But when I modify the quantity or adding new line it's not updation same time until I click on next line. Why someone will click on next line?....
André Arnaud de Cal...
294,157
Super User 2025 Season 1
Martin Dráb
232,930
Most Valuable Professional
nmaenpaa
101,158
Moderator