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

Community site session details

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

Programmatically assign Invoice Number while Posting from Sales Order

(2) ShareShare
ReportReport
Posted on by 3,944
When we post Sales Invoice from Sales Order in BC, the Invoice number is assigned based on No. Series. Is it possible to programmatically assign manual Invoice Number? For example, when user Post Invoice, the Invoice Number would be based on Customer PO Number in Sales Order with a Prefix, such as "INV-<Customer PO>"
Thank you.
 
 
 
I have the same question (0)
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,511 Super User 2025 Season 2 on at
    Programmatically assign Invoice Number while Posting from Sales Order
    I don't think its possible in standard Business Central but would be done using custom code. But why do you need to Customer PO in invoice. You can create custom flow field to track the customer POs
     
    Thanks!
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
  • Gerardo Rentería García Profile Picture
    23,574 Most Valuable Professional on at
    Programmatically assign Invoice Number while Posting from Sales Order
  • Suggested answer
    YUN ZHU Profile Picture
    92,727 Super User 2025 Season 2 on at
    Programmatically assign Invoice Number while Posting from Sales Order
    This needs to be customized, or you need to enter it manually each time. Hopefully the following information can give you some hints
    Dynamics 365 Business Central: Manual number for Posted Sales invoice and Posted Purchase invoice (Use the same number in Sales Order and Posted Sales Invoice?)
    Thanks.
    ZHU
  • Suggested answer
    Mansi Soni Profile Picture
    8,876 Super User 2025 Season 2 on at
    Programmatically assign Invoice Number while Posting from Sales Order
    Hello,

    Yes, it is possible to assign a custom invoice number like "INV-" when posting a Sales Invoice from a Sales Order in Business Central, but it requires customization. By default, the system uses the No. Series for invoice numbering, and overriding this behavior programmatically involves customizing the posting routine to fetch the Customer PO number and assign it as the invoice number with a prefix. This must be done carefully to ensure uniqueness and maintain data integrity.

    Hope this answer will help you!

    Regards,
    Mansi Soni
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,087 Super User 2025 Season 2 on at
    Programmatically assign Invoice Number while Posting from Sales Order
     
    In standard Business Central, the invoice number is strictly controlled by the No. Series defined in the Sales & Receivables Setup and assigned on the Sales Header. Business Central does not support manual invoice numbering during posting due to audit trail and data integrity constraints.
     
    However, to achieve what you're asking — assigning the invoice number programmatically based on the Customer PO No. — you'd need to:
     
    1. Create a customization in AL.
     
     
    2. Use the OnBeforeInsertSalesInvoiceHeader event in the Codeunit 80 "Sales-Post" to override the No. field before the invoice is created.
     
     
    3. Validate that the number you assign does not conflict with existing entries and aligns with any required number series settings.
     
     
     
    Keep in mind:
     
    You might face restrictions when trying to bypass the No. Series enforcement.
     
    Doing this can break future posting and integration logic (like e-invoicing or audit expectations).
     
    A safer alternative is to keep the standard number, but include the Customer PO No. prominently in the external document number or description field on the invoice.
     
     
    ✅ Mark this answer as verified if it helps you.
     
     
  • Suggested answer
    RockwithNav Profile Picture
    8,344 Super User 2025 Season 2 on at
    Programmatically assign Invoice Number while Posting from Sales Order
    There's a column which says Posting No on the Order, enable this and put it on the order screen, whatever value you will feed in this that will be used as Posted Invoice No.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,308

#2
Sumit Singh Profile Picture

Sumit Singh 2,798

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,793

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans