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, ...
Unanswered

How to get data from custPackingSlipTrans to custinvoiceJour table with custom fields using x++

(1) ShareShare
ReportReport
Posted on by 406
Hi,
in packing slip journal lines, i need to get the values of this custom field "Foam Qty" from custpackingslipTrans table
i want to show those values in the Foam Quantity field in the CustInvoiceTrans  table.
 
i need the code for this one and which methods should i create / extend.
 
thanks
I have the same question (0)
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    Well, how do you want to decide which invoice line is related to which packing slip line?
     
    For example, I have an order with two pieces. I post two packing slips, each with a single piece. Now I post an invoice. If it's for one piece, which packing slip it is?
     
    By the way, what does the Foam Qty represent and how does it get into the packing slip lines?
  • D365FO DEV Profile Picture
    406 on at
    Hi martin,
    FoamQty is a custom field.
    regarding ur question, for the invocie journal, each packingslip has am invoiceid.
    i have tried the inserting event handler of custinvoicetrans table.
    here is the code:
     
     
     [DataEventHandler(tableStr(CustInvoiceTrans), DataEventType::Inserting)]
        public static void CustInvoiceTrans_onInserting(Common sender, DataEventArgs e)
        {
            CustInvoiceTrans custInvoiceTrans = sender as CustInvoiceTrans;
            CustPackingSlipTrans    custPackingSlipTrans;
            CUSTINVOICEJOUR localCUSTINVOICEJOUR;
            CUSTINVOICETRANS localCUSTINVOICETRANS;
            InventTrans             inventTrans;
            InventTransOrigin       inventTransOrigin;

            while select FOAMQty from custPackingSlipTrans
                join localCUSTINVOICETRANS join inventTransOrigin join inventTrans
                where custPackingSlipTrans.InventTransId     == custInvoiceTrans.InventTransId
                &&    custPackingSlipTrans.InventTransId     == inventTransOrigin.InventTransId
                &&    inventTrans.InventTransOrigin          == inventTransOrigin.RecId
                &&    inventTrans.PackingSlipId              == custPackingSlipTrans.PackingSlipId
                    &&    inventTrans.InvoiceId                  == custInvoiceTrans.invoiceId
                && localCUSTINVOICETRANS.SALESID == CUSTPACKINGSLIPTRANS.SALESID
                && localCUSTINVOICETRANS.INVOICEID == custInvoiceTrans.INVOICEID
            {
                CustInvoiceTrans.Ex_FoamQty = CustPackingSlipTrans.FOAMQty;
            }
        }
     
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    You said there is InvoiceId on packing slip, but even if it contains something useful, you never use it in your code. Let me ignore this information; you code is using a relation over InventTransId, which is probably correct.
     
    Regarding your code, you forgot to tell us what problem you have with it. First of all, check if the query returns the expected data. That will tell you whether you have a bug in the query or just in the code assigning the value. The latter part is wrong for sure, but if the query doesn't work, you must fix that first.
  • D365FO DEV Profile Picture
    406 on at
    hi martin,
     
    the purpose of this all is to display the value of the field FoamQty on the sales invoice report. so once i be able to get the data from custpackingsliptrans to custinvoicetrans, then i change the logic in the DP class and populate the data.
    based on my requirements, can you provide the correct source code to make this happen?
     
    Thanks
  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at
    Are you saying you aren't willing to test your own code at all? Maybe it already works or it needs just a little adjustment.
     
    Writing code, sharing it with us and then ignoring it and asking us for other (or maybe even the same) code sounds strange to me.
  • D365FO DEV Profile Picture
    406 on at
    My question for you is which table/form/method i should use my code in? 
    So lets say once i form the invoice journal lines form, the field must be showing the values populated from the packing slip lines form.
    I used inserted event handler but it didnt work out.

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 March 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 658

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans