Hi all,
I'm continuing my testing of coding on BC and have come across a requirement that involves adding a line to the Sales Order form for Gross Profit Margin.
In my testing i found that I couldn't get the Unit Cost of the item on the sales Line as it was in the Item table.
So my thinking was, i should try to get it on the Item lookup table just as a starting position.
This is the code i used
tableextension 50112 GPM extends Item
{
fields
{
field(50113; UC2; Decimal)
{
TableRelation = item."Unit Cost" where("No." = field("No."));
}
field(50112; GPM; Decimal)
{
DataClassification = ToBeClassified;
Caption = 'GPM';
}
}
procedure GetGPM(): Decimal
begin
calcfields("Unit Price", "Unit Cost");
exit(Rec."Unit Price" - Rec."Unit Cost");
end;
}
pageextension 50112 GPM extends "Item Lookup"
{
layout
{
addafter("Unit Cost")
{
field(GPM; Rec.GPM)
{
ApplicationArea = all;
caption = 'GPM';
}
}
}
it returns 0.00 for everything can someone guide me ?
Thanks!
coding noob