Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

to get the invoice no against packing slip

(0) ShareShare
ReportReport
Posted on by 1,479
hi ,
I want to add the field invoice no in the form in the form against packing slip how can I get it done can anybody guide me on this .
 
 
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    to get the invoice no against packing slip
    hi 
    martin,
     
    ok i will create new thread .
     
    thanks ,
    regards ,
    Dinesh.
     
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    to get the invoice no against packing slip
    Yes, creating a batch job is possible, although I wouldn't do it for such an one-time job.
     
    If you insist on creating batch job but you don't know how to create one, please create a new thread for it, because it's a different topic than how "to get the invoice no against packing slip".
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    to get the invoice no against packing slip
    hi
    martin ,
     
    Is it possible if i can create the batch job which will update all existing packing slips invoice id's  but i without contract class . but how can i make it can you please guide me on this .
     
    thanks,
    regards ,
    dinesh
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    to get the invoice no against packing slip
    Do you mean that you want to update existing packing slips? If so, you can create a runnable class to iterate packing slips, use your code to try to find on of the invoice IDs for each packing slip (which may but doesn't have to succeed, even if an invoice exist), and if found, put the ID to the packing slip and update the record.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    to get the invoice no against packing slip
     hi martin 
    thanks for helping me out , i am getting the invoice id updated , can you tell me how can i update the previous invoice ids. because this code will update only recently updated invoiceid.
     
    thanks ,
     regards,
    Dinesh
  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    to get the invoice no against packing slip
    That's correct. Invoice posting has almost nothing to do with packing slips and therefore invoice posting does not refer to CustPackingSlipJour. It's what you want to change. If the logic you want was already there, you wouldn't need to develop your customization.
     
    You already have code to find and update a CustPackingSlipJour record, so if you want to ignore all the bugs there, you can simply move it from INVCustPackingSlipJour_Extension.update() to an extension of CustPostInvoice)
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    to get the invoice no against packing slip
    hi 
    martin 
    i have checked  CustPostInvoice class there is no mention of method or table custpackingslipjour table  so when the invoice id is generated the how it is possible to update the entry in the custpackingslipjour. invoiceid because all the packing slip data goes in this table .so do you mean i should extend the custpost invoice class and find create the method getinvoice id and when the invoice get posted my class should be call and invoice should get inserted into custpacking slip jour table . let me know should i try doing this .
     
    thanks,
    regards ,
    Dinesh 
  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    to get the invoice no against packing slip
    It's an infinite loop because you're updating CustPackingSlipJour from update of the same record, which calls update() again, and update() again call update(), and so on...
     
    It can be solved, but you've just confirmed that you actually want to do it at a completely different place, so the fix of the INVCustPackingSlipJour_Extension.update() is deleting it.
     
    Invoice posting happens in CustPostInvoice class.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,479 on at
    to get the invoice no against packing slip
    hi ,
    martin ,
     you are right i want to run my logic when the invoice get posted , i also have made the changes in update method but the debugger is looping in infinite loop in my update method and i tried to debug the code of custpackingslipjour but i am not getting any solution . i have corrected my code its not working 
    [ExtensionOf(tableStr(CustPackingSlipJour))]
    final class INVCustPackingSlipJour_Extension
    {
        public void update()
        {
            CustPackingSlipJour    custPackingSlipJour;
            CustPackingSlipTrans   custPackingSlipTrans;
            CustInvoiceTrans       custInvoiceTrans;
            CustInvoiceJour        custInvoiceJour;
    
            next update();
    
            ttsbegin;
            select forupdate custPackingSlipJour
                where custPackingSlipJour.SalesId == this.SalesId
                &&    custPackingSlipJour.PackingSlipId == this.PackingSlipId
                join  custPackingSlipTrans
                where custPackingSlipTrans.SalesId  == this.SalesId
                  &&  custPackingSlipTrans.PackingSlipId == this.PackingSlipId      
                  &&  custPackingSlipTrans.DeliveryDate == this.DeliveryDate
                join  custInvoiceTrans
                where custInvoiceTrans.InventTransId == custPackingSlipTrans.InventTransId
                join  custInvoiceJour
                where custInvoiceJour.SalesId == custInvoiceTrans.SalesId
                &&  custInvoiceJour.InvoiceId == custInvoiceTrans.InvoiceId;
    
    
              custPackingSlipJour.InvoiceId =  custInvoiceTrans.InvoiceId;
              custPackingSlipJour.update();
            ttscommit;
          
        }
    }
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    to get the invoice no against packing slip
    According to your code, your answer to my question seems to be: "I don't care which packing slip belongs to which invoice. I simply take the first one I find.".
     
    I see three problems in your code:
    1. You set the value after the record was saved and you don't save the record on your own, therefore your change isn't saved.
    2. I think you want to run your logic when posting an invoice, but your code is at a completely different place. It runs only when a packing slip is updated and it's not clear to me when it happens, if at all.
    3. Your code doesn't ignores summary and partial postings. Each invoice and packing slip can contain multiple orders, and each order line may be included in several packing slips and invoices. Pay attention to tables like CustInvoiceSalesLink.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans