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 :
Finance | Project Operations, Human Resources, ...
Answered

to get the invoice no against packing slip

(0) ShareShare
ReportReport
Posted on by 1,836
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 .
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    236,877 Most Valuable Professional on at
    to get the invoice no against packing slip
    How should it work? Let's say I have an order with two pieces of an item. I create two packing slips (A and B), each for a single piece. Then I create a invoice for one piece. How will you decide whether the invoice is related to packing slip A or B?
  • Dineshkarlekar Profile Picture
    1,836 on at
    to get the invoice no against packing slip
    hi 
     martin,
     if two packing slip for one sales order and one is invoiced its invoice no. should be updated and if another packing slip which is not invoiceed its invoice no should be blank . so i use the packing slip no from cust invoice jour table but still the question is how to find which invoice is for which packing slip .

    thanks ,
     regards,
    Dinesh.
     
     
  • Verified answer
    Martin Dráb Profile Picture
    236,877 Most Valuable Professional on at
    to get the invoice no against packing slip
    Okay, so you also don't know. You'll have to go to the person who raised this requirement and asked about the required business logic. And maybe you'll need to explain that there is no such relation at moment (as far as we know). Either a new business process will be needed to relate invoices and packing slips, if it's worth doing, or the requirement will have to be reject as not feasible.
  • Hana Xue Profile Picture
    Microsoft Employee on at
    to get the invoice no against packing slip
  • Verified answer
    Martin Dráb Profile Picture
    236,877 Most Valuable Professional on at
    to get the invoice no against packing slip
    Maybe I'm wrong, but still I don't think that either of these steps provide the answer. Yes, we can find the lot ID (InventTransId), but there will be two transactions with this lot ID, each for a different packing slip.
  • Dineshkarlekar Profile Picture
    1,836 on at
    to get the invoice no against packing slip
    hi , 
    martin
    i have created simple coc to update the invoiceid in table , correct me if i am wrong my code is below 
    [ExtensionOf(tableStr(CustPackingSlipJour))]
    final class INVCustPackingSlipJour_Extension
    {
        public void update()
        {
            CustPackingSlipJour    custPackingSlipJour;
            CustPackingSlipTrans   custPackingSlipTrans;
            CustInvoiceTrans       custInvoiceTrans;
            CustInvoiceJour        custInvoiceJour;
    
            next update();
    
            ttsbegin;
              select forupdate custPackingSlipJour
                join  custPackingSlipTrans
                where custPackingSlipTrans.PackingSlipId == this.PackingSlipId
                join  custInvoiceTrans
                where custInvoiceTrans.InventTransId == custPackingSlipTrans.InventTransId
                join  custInvoiceJour
                where custInvoiceJour.SalesId == custInvoiceTrans.SalesId
                  &&  custInvoiceJour.InvoiceId == custInvoiceTrans.InvoiceId;
    
              custPackingSlipJour.InvoiceId =custInvoiceTrans.InvoiceId;
            ttscommit;
                
        }
    }
    thanks,
    regards ,
    dinesh
  • Dineshkarlekar Profile Picture
    1,836 on at
    to get the invoice no against packing slip
    hi ,
    martin 
    i am getting the value in sql but the value is not getting updated when i invoice the salesorder , can you tell me any changes in my code .
     
    thanks ,
    regards,
     Dinesh
  • Martin Dráb Profile Picture
    236,877 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.
  • Dineshkarlekar Profile Picture
    1,836 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
    236,877 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.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 734 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 636

#3
Martin Dráb Profile Picture

Martin Dráb 553 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans