ALAppExtensions
ALAppExtensions copied to clipboard
table 55 "Invoice Posting Buffer" BuildPrimaryKey procedure
Hi, Is it possible to change BuildPrimaryKey procedure like below. I think it will be more extensible.
Microsoft_Base Application_19.0.29956.0
Standart Procedure
procedure BuildPrimaryKey()
var
GroupID: Text;
TypeValue: Integer;
begin
TypeValue := Type.AsInteger();
GroupID :=
Format(TypeValue) +
PadField("G/L Account", MaxStrLen("G/L Account")) +
PadField("Gen. Bus. Posting Group", MaxStrLen("Gen. Bus. Posting Group")) +
PadField("Gen. Prod. Posting Group", MaxStrLen("Gen. Prod. Posting Group")) +
PadField("VAT Bus. Posting Group", MaxStrLen("VAT Bus. Posting Group")) +
PadField("VAT Prod. Posting Group", MaxStrLen("VAT Prod. Posting Group")) +
PadField("Tax Area Code", MaxStrLen("Tax Area Code")) +
PadField("Tax Group Code", MaxStrLen("Tax Group Code")) +
Format("Tax Liable") +
Format("Use Tax") +
PadField(Format("Dimension Set ID"), 20) +
PadField("Job No.", MaxStrLen("Job No.")) +
PadField(Format("Fixed Asset Line No."), 20) +
PadField("Deferral Code", MaxStrLen("Deferral Code")) +
PadField("Additional Grouping Identifier", MaxStrLen("Additional Grouping Identifier"));
"Group ID" := CopyStr(GroupID, 1, MaxStrLen("Group ID"));
OnAfterBuildPrimaryKey(Rec);
end;
Standart Procedure
Modified Procedure
procedure BuildPrimaryKey(var GruopedInvoicePostingBuffer: Record "Invoice Posting Buffer")
begin
GruopedInvoicePostingBuffer.Reset;
GruopedInvoicePostingBuffer.SetRange(Type, Type);
GruopedInvoicePostingBuffer.SetRange("G/L Account", "G/L Account");
GruopedInvoicePostingBuffer.SetRange("Gen. Bus. Posting Group", "Gen. Bus. Posting Group");
GruopedInvoicePostingBuffer.SetRange("Gen. Prod. Posting Group", "Gen. Prod. Posting Group");
GruopedInvoicePostingBuffer.SetRange("VAT Bus. Posting Group", "VAT Bus. Posting Group");
GruopedInvoicePostingBuffer.SetRange("VAT Prod. Posting Group", "VAT Prod. Posting Group");
GruopedInvoicePostingBuffer.SetRange("Tax Area Code", "Tax Area Code");
GruopedInvoicePostingBuffer.SetRange("Tax Group Code", "Tax Group Code");
GruopedInvoicePostingBuffer.SetRange("Tax Liable", "Tax Liable");
GruopedInvoicePostingBuffer.SetRange("Use Tax", "Use Tax");
GruopedInvoicePostingBuffer.SetRange("Dimension Set ID", "Dimension Set ID");
GruopedInvoicePostingBuffer.SetRange("Job No.", "Job No.");
GruopedInvoicePostingBuffer.SetRange("Fixed Asset Line No.", "Fixed Asset Line No.");
GruopedInvoicePostingBuffer.SetRange("Deferral Code", "Deferral Code");
GruopedInvoicePostingBuffer.SetRange("Additional Grouping Identifier", "Additional Grouping Identifier");
OnBuildPrimaryKeyOnBeforeFind(GruopedInvoicePostingBuffer, Rec);
if GruopedInvoicePostingBuffer.Find('-') then
"Group ID" := GruopedInvoicePostingBuffer."Group ID"
else
"Group ID" := UpperCase(Format(CreateGuid(), 0, 4));
GruopedInvoicePostingBuffer.Reset();
OnAfterBuildPrimaryKey(Rec);
end;
[IntegrationEvent(false, false)]
local procedure OnBuildPrimaryKeyOnBeforeFind(var GruopedInvoicePostingBuffer: Record "Invoice Posting Buffer"; var Rec: Record "Invoice Posting Buffer")
Modified Procedure
Internally closed as "Won't Fix" by @AlexanderYakunin. Syncing state to GitHub.