I am looking at your example and tried to adapt it to my factbox. I could not add modify keyword inside the layout.
The first error is this:
Syntax error, '}' expected
The second error is this:
Expected one of the application object keywords (table, tableextension, page, pageextension, pagecustomization, profile, codeunit, report, reportextension, xmlport, query, controladdin, dotnet, enum, enumextension, interface, permissionset, permissionsetextension, entitlement)
If i try to create an extension for my factbox, there is no error on modify keyword but I get a dffirent error that looks like this:
The extension object 'MyPageExtensionFactbox' cannot be declared. Another extension for target 'Sales Line Custom Factbox 2' or the target itself is already declared in this module.
There is no second extension for my 'Sales Line Custom Factbox 2'.
Do I declare the extension in another module, do I need to create a new Al Project and write the factbox extension there?
My second question is regarding declaring new fields inside the factbox extension. I need to create four custom fields. Two fields are calculated by using the fields inside their Sales Line. The two other fields are calculated by adding those custom fileds result form each sales line.
this is my code snippet:
pageextension 56004 PageExtension56004 extends "Sales Line Custom Factbox 2"
{
layout
{
addafter(SalesUnitCalculation)
{
group(SalesLineCalculation)
{
Caption = 'Sales Line Calculation';
field("Line Amount"; "Line Amount")
{
ApplicationArea = Basic, Suite;
Caption = 'Line Amount';
}
field(LineCost; LineCost)
{
Caption = 'Line Cost';
ApplicationArea = All;
Editable = false;
Visible = false;
}
field(LineProfit; LineProfit)
{
Caption = 'Line Profit';
ApplicationArea = All;
Editable = false;
Visible = false;
}
}
group(SalesTotalCalculation)
{
Caption = 'Sales Total Calculation';
field("Total Amount"; TotalAmount)
{
ApplicationArea = Basic, Suite;
Caption = 'Total Amount Incl. VAT';
}
field(TotalCost; TotalCost)
{
Caption = 'Total Cost';
ApplicationArea = All;
Editable = false;
}
field(TotalProfit; TotalProfit)
{
Caption = 'Total Profit';
ApplicationArea = All;
Editable = false;
}
}
}
modify("Unit Cost")
{
trigger OnAfterValidate()
begin
UpdateLineCostAndLineProfit();
UpdateTotalCostAndTotalProfit();
end;
}
modify(Quantity)
{
trigger OnAfterValidate()
begin
UpdateLineCostAndLineProfit();
UpdateTotalCostAndTotalProfit();
end;
}
}
trigger OnAfterGetRecord()
begin
end;
trigger OnAfterGetCurrRecord()
begin
UpdateLineCostAndLineProfit();
UpdateTotalCostAndTotalProfit();
end;
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
UpdateLineCostAndLineProfit();
UpdateTotalCostAndTotalProfit();
end;
trigger OnDeleteRecord(): Boolean
begin
UpdateLineCostAndLineProfit();
UpdateTotalCostAndTotalProfit();
end;
var
LineCost: Decimal;
LineProfit: Decimal;
TotalCost: Decimal;
TotalProfit: Decimal;
///
/// UpdateLineCostAndLineProfit.
///
procedure UpdateLineCostAndLineProfit()
var
SalesLine: Record "Sales Line";
begin
LineCost := 0;
LineProfit := 0;
SalesLine.Reset();
SalesLine.CopyFilters(Rec);
LineCost := Quantity * "Unit Cost";
LineProfit := "Line Amount" - LineCost;
end;
///
/// UpdateTotalCostAndTotalProfit.
///
procedure UpdateTotalCostAndTotalProfit()
var
SalesLine: Record "Sales Line";
begin
TotalCost := 0;
TotalProfit := 0;
SalesLine.Reset();
SalesLine.CopyFilters(Rec);
SalesLine.CalcSums(LineCost);
SalesLine.CalcSums(LineProfit);
TotalCost := SalesLine.LineCost;
TotalProfit := SalesLine."Line Amount" - TotalCost;
end;
}
I get the folowing errors:
Argument 1: must be a member
'Record "Sales Line"' does not contain a definition for 'LineCost'