Hello,
Find super good extension - https://yzhums.com/11138/
think hmm it would be super nice if i cound do the same but in every sale order and calculate weight so, my journey has started...
tried tried and something i did that debugger goes without error, but... when selected sale order lines in sales order and press calculate getting error "The table IDs do not match."
used this code
[code]
table 50105 TotalSalesOrderLines
{
DataClassification = CustomerContent;
Caption = 'Total Sales Order Lines';
fields
{
field(1; Number; Integer)
{
Caption = 'Number';
DataClassification = CustomerContent;
}
field(2; LineCount; Integer)
{
Caption = 'Line Count';
DataClassification = CustomerContent;
}
field(3; LinesAverage; Decimal)
{
Caption = 'Average';
DecimalPlaces = 0 : 5;
}
field(15; Quantity; Decimal)
{
Caption = 'Quantity';
DecimalPlaces = 0 : 5;
}
field(29; Amount; Decimal)
{
Caption = 'Amount';
Editable = false;
}
field(30; TotalWeight; Decimal)
{
Caption = 'Total Weight';
Editable = false;
}
}
keys
{
key(PK; Number)
{
Clustered = true;
}
}
}
page 50106 "Sales Order Lines Total"
{
PageType = CardPart;
Editable = false;
SourceTable = TotalSalesOrderLines;
layout
{
area(Content)
{
field(LineCount; Rec.LineCount)
{
Caption = 'Count';
ApplicationArea = All;
}
field(LinesAverage; Rec.LinesAverage)
{
Caption = 'Average';
ApplicationArea = All;
}
field(Amount; Rec.Amount)
{
Caption = 'Total Amount';
ApplicationArea = All;
}
field(Quantity; Rec.Quantity)
{
Caption = 'Total Quantity';
ApplicationArea = All;
}
field(TotalWeight; Rec.TotalWeight)
{
Caption = 'Total Weight';
ApplicationArea = All;
}
}
}
procedure SetTotals(var NewLineCount: Integer; NewAverage: Decimal; NewTotalAmount: Decimal; NewTotalQuantity: Decimal; NewTotalWeight: Decimal)
begin
Rec.Reset();
Rec.DeleteAll();
Rec.Init();
Rec.Number := 1;
Rec.LineCount := NewLineCount;
Rec.LinesAverage := NewAverage;
Rec.Amount := NewTotalAmount;
Rec.Quantity := NewTotalQuantity;
Rec.TotalWeight := NewTotalWeight;
Rec.Insert();
end;
}
pageextension 50103 SalesOrderPageExt extends "Sales Order"
{
layout
{
addfirst(FactBoxes)
{
part(SelectedSalesOrderLinesTotal; "Sales Order Lines Total")
{
Caption = 'Sales Order Lines Total';
ApplicationArea = All;
SubPageLink = Number = const(2);
}
}
}
actions
{
addbefore("F&unctions")
{
action("Calculate Total")
{
Caption = 'Calculate Total';
ApplicationArea = All;
Promoted = true;
PromotedIsBig = true;
PromotedCategory = Process;
Image = Calculate;
trigger OnAction()
var
SelectedSalesLines: Record "Sales Line";
TotalAmount: Decimal;
TotalQuantity: Decimal;
TotalWeight: Decimal;
LinesCount: Integer;
LinesAverage: Decimal;
LineWeight: Decimal;
begin
SelectedSalesLines.Reset();
LinesCount := 0;
LinesAverage := 0;
TotalAmount := 0;
TotalQuantity := 0;
TotalWeight := 0;
CurrPage.SetSelectionFilter(SelectedSalesLines);
if SelectedSalesLines.FindSet() then begin
repeat
LinesCount += 1;
TotalAmount += SelectedSalesLines.Amount;
TotalQuantity += SelectedSalesLines.Quantity;
LineWeight := SelectedSalesLines."Net Weight" * SelectedSalesLines.Quantity;
TotalWeight += LineWeight;
until SelectedSalesLines.Next() = 0;
end;
if LinesCount > 0 then begin
LinesAverage := TotalAmount / LinesCount;
CurrPage.SelectedSalesOrderLinesTotal.Page.SetTotals(LinesCount, LinesAverage, TotalAmount, TotalQuantity, TotalWeight);
CurrPage.SelectedSalesOrderLinesTotal.Page.Update();
end;
end;
}
action("Clear Total")
{
Caption = 'Clear Total';
ApplicationArea = All;
Promoted = true;
PromotedIsBig = true;
PromotedCategory = Process;
Image = ClearLog;
trigger OnAction()
begin
ClearTotal();
end;
}
}
}
trigger OnOpenPage()
begin
ClearTotal();
end;
local procedure ClearTotal()
var
TotalSalesOrderLines: Record TotalSalesOrderLines;
begin
TotalSalesOrderLines.Reset();
TotalSalesOrderLines.DeleteAll();
end;
}
[/code]
Tried something else but nowstill not working
[code]