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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Invoice Sales Order while doing Packing slip through code of x++

(0) ShareShare
ReportReport
Posted on by 436

Hi Expert,

While doing packing slip i also want to invoice sales order while clicking OK button.

pastedimage1570712131968v1.png

Please suggest me the right path

Thanks

Sona Jee

I have the same question (0)
  • Verified answer
    Pedro Tornich Profile Picture
    955 on at

    Hi Sona Jee,

    You can create an extension of the PurchPackingSlipJournalPost class to trigger the invoice process right after the packing slip.

    Also, to post the invoice based on a packing slip you will have to use the salesFormLetter.selectFromJournal() parameter.

    Here is an example:

    [ExtensionOf(classStr(SalesPackingSlipJournalPost))]
    final class salesPackingSlipJournalPost_Extension
    {
        public void postJournalPost()
        {
            next postJournalPost();
    
            this.postInvoice();
        }
        
        public CustInvoiceJour postInvoice()
        {
            TmpFrmVirtual tmpFrmVirtual;
    
            tmpFrmVirtual.TableNum = custPackingSlipJour.TableId;
            tmpFrmVirtual.RecordNo = custPackingSlipJour.RecId;
            tmpFrmVirtual.insert();
    
            List packingSlipList = new List(Types::Record);
            packingSlipList.addEnd(tmpFrmVirtual);
    
            SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
    
            SalesTable salesTable = custPackingSlipJour.salesTable();
    
            salesFormLetter.salesTable  (salesTable);
            salesFormLetter.transDate   (salesParmTable.TransDate);
            salesFormLetter.specQty     (SalesUpdate::PackingSlip);
            salesFormLetter.proforma    (NoYes::No);
    
            SalesParmUpdate salesParmUpdate = salesFormLetter.salesParmUpdate();
            
            salesFormLetter.initParameters(salesParmUpdate, Printout::Current);
            salesFormLetter.chooseLines(true);
            salesFormLetter.selectFromJournal(packingSlipList.pack());
            
            salesFormLetter.run();
    
            return salesFormLetter.parmJournalRecord();
        }
    
    }

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    Packing slip and invoice posting are two separate processes. What business scenario forces you to do  invoice posting during pacing slip process ?  It wont be possible without modification.

    You can check in the code if the packing slip  posting process is finished and then trigger the invoice process , however you have to be extra cautious while doing such a modification, as such a modification can lead to different kind of issues. Also make sure you think about different scenarios , if you are modifying system.

  • Suggested answer
    SouravDam Profile Picture
    11,732 on at

    Hi Sona Jee,

    Appreciate if you kindly explain such business requirement and why it is required like this!

    I think this is a vague idea to post invoice at the time of packing slip posting.

    Like what Sukrut mentioned; why such requirement is to implement when there will be lot of risk factors involved. Below could be some of the reasons why it should not be performed like that.

    --- How would you know what will be the invoice date if you try to post it at the time of packing slip?

    --- If you need to adjust any tax amount at the time of invoicing; how you will manage that?

    --- How you will settle any open transactions with invoice?

    --- If you want to go for partial invoicing; how you will manage it?

    Is there any integration you have done with D356 which will flow invoices and that you have to post at the same time of packing slip? Even if the answer is 'Yes'; you can do that even after posting the packing slip.

    Kindly update.

    Best regards,
    Sourav Dam

    Please take time to click 'Yes' against the answers that help you guide in right direction to help other community members.

  • Suggested answer
    Satish Panwar Profile Picture
    14,673 Moderator on at

    Hi Sona,

    You can setup standard batch job for invoicing and save yourself from customization unless you really have a business requirement to do it.

    Thanks,

    Satish Panwar

    Please take time to click 'Yes' against the answers that help you guide in right direction to help other community members.

  • Suggested answer
    Khushhal Garg Profile Picture
    1,514 on at

    If it is required to be synchronous process to post invoice and packing slip together then it requires customization

  • Sona Jee Profile Picture
    436 on at

    Hi Pedro,

    It worked for me.

    Thanks

  • Community Member Profile Picture
    on at

    Great Work. I also got some same requirements and your solution works fine for me

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 804

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 639 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 528

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans