How to transfer a new custom field from sales order to the Fa ledger entry?

how to transfer a new custom field from sales order to the Fa ledger entry?
i created one field in sales header and i created one fa ledger entries
For ex : Test Field how should i carry the data where should write the code in code unit can tell me the function and code unit number

Hi @Sai_Shiva,

First of all, saler order doesn’t create FA Ledger Entry… if you mean when posting an invoice from Sales Order, ok, we can go through the process…

You must add this new fields to General Journal Line and Invoice Posting Buffer (or Invoice Post. Buffer in earlier versions) tables.

Then you must transfer the data from sales header/line to the buffer (you can use OnAfterPrepareSales event from buffer, bear in mind that the info in buffer is grouped, but if there is a Fixed Asset, this is not a problem, will not be grouped).

Transfer from buffer to General Journal Line (use OnAfterCopyToGenJnlLine event from buffer table).

Finally from General Journal Line, transfer data to FA Ledger Entry (using CopyFromGenJnlLine from codeunit “Make FA Ledger Entry”).

Best regards.

1 Like

To transfer data from a custom field in a sales order to the corresponding field in the FA ledger entry, you will need to modify the code unit that handles the transfer of data between the sales order and the FA ledger entry. This code unit is typically called “Post Inventory Cost to G/L” (code unit number 5898 in Microsoft Dynamics NAV).

Here’s an overview of the steps you can take:

  1. In the sales order table, create a new field for the data you want to transfer to the FA ledger entry. In this case, you have already created the “Test Field” in the sales header.

  2. In the FA ledger entry table, create a corresponding field to hold the data from the sales order.

  3. Open the “Post Inventory Cost to G/L” code unit and find the function that transfers data from the sales order to the FA ledger entry. This function is typically called “CreateFAEntriesFromSourceDoc” or “CreateFALinesFromSourceDoc”.

  4. In this function, find the code that copies data from the sales order fields to the corresponding fields in the FA ledger entry. Add code to copy the data from your custom field in the sales order to the corresponding field in the FA ledger entry. Here’s an example of what this code might look like:
    IF SalesHeader.TESTFIELD <> ‘’ THEN BEGIN
    FALedgerEntry.TESTFIELD := SalesHeader.TESTFIELD;
    END;
    This code checks if the “Test Field” in the sales order is not blank, and if so, copies the data to the corresponding field in the FA ledger entry.

  5. Compile and test your changes to make sure the data is being transferred correctly.

Note that these steps are general guidelines and may need to be modified depending on the specific version and configuration of your Dynamics NAV system. You should also ensure that any customizations you make are thoroughly tested in a development or test environment before being deployed to your live system.

Thank You For Your replay

You are welcome. Please mark my answer as the solution if it helped you to solve your problem.