Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

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

Posted on by Microsoft Employee

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

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: How can I customize post sales order to Posted sales Invoice?

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

    please verify, if your question is answered.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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.

  • Verified answer
    Genie Cetas Profile Picture
    Genie Cetas 472 on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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.

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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
    keoma 32,675 on at
    RE: How can I customize post sales order to Posted sales Invoice?

    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>

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans