Home » knowledge » Post Custom field value into Customer Ledger Entry from sales invoice / order

Post Custom field value into Customer Ledger Entry from sales invoice / order

Hello guys, Today I will share how to post your custom filed values into Customer Ledger Entry. First let me explain how it works in version 2009. In 2009, You need to follow few simple steps to post your customs field. In theory it happens like this, When you post Sales Order or Sales invoice, it will call codeunit 80 (Sales-Post) . So after that there will have so many functions and there is a function to write into Gen. Journal Line (Table 81)  and call the codeunit 12 (Gen. Jnl.-Post Line) . Inside CU 12 we have so many functions but we need to check which function write data into Customer Ledger Entry.

So if you look carefully there is  function called PostCust , So inside that function you have to write your code.

Okay, let’s begin it practically.

I will add a field in Sales Header table which is Custom Field, It is code type length is 10 . So same field I will add to table 81 and table 21.

Then I will go into codeunit 80 and search by .init ( till I found Genline.init) when you search you can find standard comment ” // Post customer entry ” so right after this comment you will see GenJnlLine.INIT; . Now we are in right place.

after GenJnlLine.INIT just add your code like follows,

 GenJnlLine.”Custom Field”:= “Custom Field”;

We have done in CU80, Now let’s move to CU12, In CU 12 you will find the Function Called PostCust ,inside this function you can write your code like follows,

 CustLedgEntry.”Custom Field” := “Custom Field”;

so now we have completed all codes. Now create a Sales order or invoice, fill your custom field and POST it.

Please comment if you have any questions.


Leave a Reply

Your email address will not be published. Required fields are marked *

Workflow Dynamics NAV 2016