I have made a custom table to copy whole data which is already posted in BANK ACCOUNT LEDGER ENTRY table .I am able to do it for once via job queue code that I have written but for new Records in bank ledger entries it is not working. Also,I have 1 field whixh is directly coming from GENERAL JOURNAL line but for that I have used same field Id.
this is the codeunit that i have used
codeunit 90127 BankAccountLedgerEntryCustom
{
VAR
SourceTableVar: Record "Bank Account Ledger Entry";
DestinationTableVar: Record BALTable;
trigger OnRun()
BEGIN
SourceTableVar.RESET;
DestinationTableVar.SetRange("Entry No.", SourceTableVar."Entry No.");
IF not
DestinationTableVar.FINDSET() THEN BEGIN
REPEAT
DestinationTableVar.INIT();
DestinationTableVar."Entry No." := SourceTableVar."Entry No.";
DestinationTableVar.Amount := SourceTableVar.Amount;
DestinationTableVar."Amount (LCY)" := SourceTableVar."Amount (LCY)";
DestinationTableVar.INSERT();
UNTIL SourceTableVar.NEXT = 0;
END
else
begin
DestinationTableVar."Statement Status" := SourceTableVar."Statement Status";
DestinationTableVar."Statement Line No." := SourceTableVar."Statement Line No.";
DestinationTableVar."Statement No.":= SourceTableVar."Statement No.";
end;
END;
}