Hi Guys,
I created a basic custom field on the Sales Header that needs to be transferred over the Sales Invoice header table. The custom field on the sales header gets populated by the same custom field on the customer table. I use the OnAfterGetCurrRecord Table Extension trigger to fetch the value from the customer custom field over to the Sales Header. This event is triggered both on the Sale Order Page as well as the Sales Invoice Page. Below is the Code:
tableextension 50208 /Customer Ext./ extends Customer
{
fields
{
field(50200; /FIN Number/; Integer)
{
Caption = 'FIN Number';
DataClassification = CustomerContent;
}
}
fieldgroups
{
addlast(Brick; /FIN Number/) { }
}
}
tableextension 50201 /Sales Header Ext./ extends /Sales Header/
{
fields
{
field(50200; /FIN Number/; Integer)
{
Caption = 'FIN No.';
}
}
}
tableextension 50207 /Sales Invoice Header Ext./ extends /Sales Invoice Header/
{
fields
{
field(50200; /FIN Number/; Integer)
{
Caption = 'FIN No.';
}
}
}
pageextension 50202 /Sales Order Ext./ extends /Sales Order/
{
layout
{
addafter(/Sell-to Customer Name/)
{
field(/FIN Number/; Rec./FIN Number/)
{
ApplicationArea = All;
caption = 'FIN No.';
Enabled = false;
}
}
}
trigger OnAfterGetCurrRecord()
var
Cust: Record /Customer/;
begin
if Cust.get(rec./Sell-to Customer No./) then
rec./FIN Number/ := cust./FIN Number/
else
rec./FIN Number/ := 0;
end;
}
pageextension 50211 /Sales Invoice Ext./ extends /Sales Invoice/
{
layout
{
addafter(/Sell-to Customer Name/)
{
field(/FIN Number/; Rec./FIN Number/) { ApplicationArea = All; Caption = 'FIN No.'; Enabled = false; }
}
}
trigger OnAfterGetCurrRecord()
var
Cust: Record /Customer/;
begin
if Cust.get(rec./Sell-to Customer No./) then
rec./FIN Number/ := cust./FIN Number/
else
rec./FIN Number/ := 0;
end;
}
For some reason that I cannot seem to figure out or probably something in my code that I am missing when I invoice a sales order the information gets transferred correctly to the Sales Invoice header table. But When I post a Sales Invoice the FIN Number field does not transfer to the Sales Invoice Header table.
What am I missing? I can confirm that the trigger events populated the fields on the sales order table correctly. So there is a value that should get transferred over to the sales invoice header. This happens for the Sales Order, but not when using the Sales Invoice. Both pages that I use the trigger on are based on the same Sales Header table.
Any help or insights would be much appreciated.