Which event to be use to update customized field in case of Prepayment. NAV 2018, BC cloud

Hi All,

I got a requirement from client to add and update Cust. No, Cust Name, SalesPerson Code and SalesOrder No. at G/L Entry level for Sales.(SO, Sales Cr Memo, Sales Prepayment Invoice, Sales PrePmt Cr Memo).

For this I added all these four field in 17 and 81 table.

Then I used OnAfterCopyGenJnlLineFromSalesHeader and OnAfterCopyGLEntryFromGenJnlLine events to update in case of SO. Its working fine.

and for Prepmt i have used OnAfterCopyGenJnlLineFromSalesHeaderPrepmt and OnAfterCopyGLEntryFromGenJnlLine.

but here it updating only in main account not in other entry. (It need to update in all general ledger entries related to that doc.)

I have written below code

in my functions :

LOCAL [EventSubscriber] CopyFromSH(SalesHeader : Record "Sales Header";VAR GenJournalLine : Record "Gen. Journal Line")
IF RecCUstomer.GET(GenJournalLine."Source No.") THEN BEGIN
GenJournalLine."Customer No." := RecCUstomer."No.";
GenJournalLine."Customer Name" := RecCUstomer.Name;
IF RecSPC.GET(RecCUstomer."Salesperson Code") THEN
GenJournalLine."Salesperson Name" := RecSPC.Name;
GenJournalLine."Sales Order No." := SalesHeader."No.";
END;

LOCAL [EventSubscriber] CopyGLEntryFromGenJrnlLine(VAR GLEntry : Record "G/L Entry";VAR GenJournalLine : Record "Gen. Journal Line")
//VAR GLEntry : Record "G/L Entry";VAR GenJournalLine : Record "Gen. Journal Line"
GLEntry."Customer No." := GenJournalLine."Customer No.";
GLEntry."Customer Name" := GenJournalLine."Customer Name";
GLEntry."Salesperson Name" := GenJournalLine."Salesperson Name";
GLEntry."Sales Order No." := GenJournalLine."Sales Order No.";

LOCAL [EventSubscriber] CopyFromSHForPrepay(SalesHeader : Record "Sales Header";VAR GenJournalLine : Record "Gen. Journal Line")
IF RecCUstomer.GET(GenJournalLine."Source No.") THEN BEGIN
GenJournalLine."Customer No." := RecCUstomer."No.";
GenJournalLine."Customer Name" := RecCUstomer.Name;
IF RecSPC.GET(RecCUstomer."Salesperson Code") THEN
GenJournalLine."Salesperson Name" := RecSPC.Name;
GenJournalLine."Sales Order No." := SalesHeader."No.";
END;

Where I am doing wrong? If require any more info kindly inform.

Thanks in Advance.

Related
Recommended