web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How can I customize post sales order to Posted sales Invoice?

(0) ShareShare
ReportReport
Posted on by

Hi Expert,

is there a way that I can customize the D365BC process when I post a sales order to create Posted Sales Invoice in Dynamics 365 Business Central.

because I need write some my custom fields to sales invocie when I doing post sales invoice.

pastedimage1587561107381v1.png

Thansk,

Ming

I have the same question (0)
  • Verified answer
    keoma Profile Picture
    32,729 on at

    add your custom fields to table sales header and also to sales invoice header. the new fields have to have the same obectids in both tables. i think, then the values are being copied.

    e.g.

    table sales header:

    50000 custfield01 <your datatype>

    table sales invoice header:

    50000 custfield01 <your datatype>

  • Community Member Profile Picture
    on at

    Hi Franz,

    Thanks for your reply, if I need execute some functions during post sales order to Posted Sales Invoice and, excute some function after posting sales order to Posted Sales Invocie, is that possible?

    Thanks again.

  • Verified answer
    keoma Profile Picture
    32,729 on at

    posting is done via codeunit 80. standard codeunits are not changeable, but there should be some events you could subscribe to. checkout onbefore and onafter events.

  • Verified answer
    Genie Cetas Profile Picture
    472 on at

    Hi Ming,

    There are multiple ways to customize this.

    Scenario : 1

    If you want to copy some field values from Sales Order to Posted Sales Invoice, you should create that field in both table with Same Field ID & datatype. If both field id & datatype are same, system automatically copy the values from Sales Order to Posted Sales Invoice. You don't need to do any code to copy the values.

    Scenario : 2

    if you want to copy field values which has different field id in both table, then you have to subscribe the below publisher to copy the values manually.

    • To copy values from Sales Line to Sales Invoice Line, You have subscribe the below event in "Sales Invoice Line" table.
      • OnAfterInitFromSalesLine
    • To copy values from Sales Header to Sales Invoice Header, You have to subscribe any one of the below event in "Sales-Post" codeunit
      • OnBeforeSalesInvHeaderInsert
      • OnAfterSalesInvHeaderInsert

    Scenario : 3

    There are many events available in "Sales-Post" codeunit. you can subscribe the events to customize based on your requirement.

  • Community Member Profile Picture
    on at

    Thanks, if I subscribe these events in my extension code, then I  post sales order to posted sales invoice in the UI, then the D365BC will execute these events automatically, is that correct?

    Thanks again.

  • Community Member Profile Picture
    on at

    Create an invoice from an order

    , and then select Orders. Select the order you want to create an invoice from. Select Create Invoice at the top of the screen. Review the contents of the invoice and make any additions or corrections before sending to your customer.

  • Verified answer
    keoma Profile Picture
    32,729 on at

    if you use these EventSubscribers, then yes it should do the needed automatically when posting an order.

    please verify, if your question is answered.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans