Skip to main content

Notifications

Announcements

No record found.

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

How to post sales or purchase invoices via different serial numbers

Posted on by

Hello Experts,

I am new to Business Central.

I just need a small help in terms of coding.

Example:

Normally when I do a purchase order, the system automatically assign the defined serial number which has been defined in Number series Table that is P-ORD (P-ORD-001 to P-ORD-099) and also which have been selected in the Purchases & Payables Setup, that is P-ORD.  That's fine.

Now, I have added a relationship when I am doing a purchase order. I can also do a purchase order interms of foreign. In the number series table it is like this: PO-ORD-F (P-ORD-F-001 to P-ORD-F-099). I have also extended the purchases and payables setup to cater for this.

Now the problem is that whenever I do a purchase order in foreign and post it, the posted invoice number takes into account the number which has been defined in the purchases & payables setup, that is like P-INV+.which is for normal purchase order.

Kindly note that I have also added the field for Posted Invoice Foreign that is PIF+ in the purchases & payables setup ,like we have for normal posted purchase invoice.

My main issue is that which code can i put and where should I put it when , whenever i do a purchase order in foreign and when I post it, it takes the number defined in purchases & payables setup under Posted Invoice Foreign. Like it picks that Posted Invoice Foreign serial number whenever the purchase order is in foreign.

Because right now when i am doing a purchase order in foreign, and when i post it, it is taking the standard posted purchase invoice number series that is P-INV+ not the one which I have customized, that is PIF+

Thanks to help me with this code.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    RE: How to post sales or purchase invoices via different serial numbers

    Hi, Yes, this can be done, but requires a little customization.

    Hope the following helps.

    https://yzhums.com/2278/

    Thanks.

    ZHU

  • Suggested answer
    Amit_Sharma Profile Picture
    Amit_Sharma 2,545 on at
    RE: How to post sales or purchase invoices via different serial numbers

    Hi,

    Do one thing. First Create two number series under Parent No. Series by using No. Series Relation feature. Then Show field in Purchase Order is "Posting No. Series";

    Now when posting, Select the number series form the "Posting No. Series" field drop down. In this way you achieve the requirement.

    No. series Creation link

    https://erpconsultors.com/creation-of-number-series-in-business-central/

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Suggested answer
    Manan_Shah Profile Picture
    Manan_Shah 1,457 on at
    RE: How to post sales or purchase invoices via different serial numbers

    Hello  AJTR,

    I never did this but I suggest. 

    You can create a field to select posting no. series on No. Series Relationships Page where you can define no. series wise it's Posting no. 

    For Example,

    On No. Series Relationships 
    1) PO Foreign = select it's Posting no. series.

    Also need to create a subscriber event when user choose PO no. system flow it's Posting no. on PO header page & Table. Which is define on No. Series Relationships. 

     
    Many Thanks,
    Manan

  • AJTR Profile Picture
    AJTR on at
    RE: How to post sales or purchase invoices via different serial numbers

    Hello Mr ZHU,

    Thanks for the reply.

    But is it possible to link this Posting No. field to Number series table so that it automatically takes the number series defined there? Like it auto increments or auto populated itself as defined in the number series table there.

    Because I have already defined the posted number series for the Purchase Order Foreign in Purchases & Payables Setup!

    Because each time when the Purchase Order will be done normally or in Foreign itself, it has to take the number series automatically.

    Like for normal purchase order, when the purchase order no. is P-ORD and when it is posted, the posted no. will become P-INV+

    Is it possible to put a code where when I will do a purchase order in foreign where the purchase order no. is PO-ORD-F (that is foreign) and when I will post it, the posted no. takes PIF+ not P-INV+

    Thanks to help me.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    RE: How to post sales or purchase invoices via different serial numbers

    Hi, As another solution, you can use the Posting No. field to specify the posting number before posting.

    Here is a simple example.

    Manual number for Posted Sales invoice and Posted Purchase invoice (Use the same number in Sales Order and Posted Sales Invoice?)

    https://yzhums.com/21537/

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: How to post sales or purchase invoices via different serial numbers

    You should subscribe to this event in the Purch.-Post codeunit

    [IntegrationEvent(false, false)]

       local procedure OnBeforeUpdatePostingNos(var PurchHeader: Record "Purchase Header"; var NoSeriesMgt: Codeunit NoSeriesManagement; var ModifyHeader: Boolean; SuppressCommit: Boolean; var IsHandled: Boolean)

       begin

       end;

    Then you can set the posting no. you want to use based on your criterias.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans