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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Value from Packing slip (CustPackingSlipJour) to SalesParmTable in SalesEditLines Form when posting Invoice

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I need to get a custom value that is available on a packing slip onto the SalesParmTable in the SalesEditLines form when I'm about to post a new invoice. 

I have created the new field, MyField, on table extensions for CustInvoiceJour, CustPackingSlipJour and SalesParmTable. I have added it on the SalesEditLines form, with SalesParmTable as the datasource. The end goal is to pass the MyField value along between the three tables in these three steps;

1. Value is set when posting a packing slip (from SalesParmTable to CustPackingSlipJour)

2. Value is visible when posting the invoice (CustPackingSlipJour to SalesParmTable)

3. Value is set on the invoice (SalesParmTable to CustInvoiceJour). 

The field is set on the SalesEditLines form when posting the packing slip, and saved to CustPackingSlipJour, with the code below: 

[ExtensionOf(classStr(SalesPackingSlipJournalCreate))]

final class SalesPackingSlipJournalCreate_Extension

{

    protected void initJournalHeader()

    {          

        next initJournalHeader();

 

        if (!custPackingSlipJour

            && isConfigurationkeyEnabled(configurationKeyNum(MCRCallCenter)))

        {      

            custPackingSlipJour.MyField = salesParmTable.MyField;       

        }               

    }

 

}

What I need to do now is the same thing but in reverse. I need to get the MyField value from CustPackingSlipJour onto SalesParmTable when I am to post the invoice for the same sales order, where the packing slip has already been created. I have tried with the code below, but it doesn't work like it is supposed to yet:

[ExtensionOf(tableStr(SalesParmTable))]

final class SalesParmTable_Extension

{

    void initFromSalesTable(SalesTable salesTable)

    {

        next initFromSalesTable (salesTable);

 

        SalesParmTable salesParmTable = this;

 

        CustPackingSlipJour custPackingSlipJour;

                        

        while select MyField, RecId from custPackingSlipJour

            where custPackingSlipJour.SalesId == salesTable.SalesId

                         {

          
                if(custPackingSlipJour.RecId == this.documentId(salesParmTable))
                {
                salesParmTable.MyField = custPackingSlipJour.MyField;
                }
                                     

             }    

    }

 

}

 

It mainly doesn't work since the if statement that is supposed to find the correct packing slip to pair up with the SalesParmTable being created doesn't work.  

if(custPackingSlipJour.RecId == this.documentId(salesParmTable)) <--- there is a type mismatch.

If I comment out the if statement it does put in the same MyField value on all SalesParmTable lines for that sales order. So, what is the correct way to connect the salesparmtable with the corresponding packing slip?

But, I feel like I am in the wrong spot and shouldn't have to loop through the packing slips like that, if anyone has done something similar (passing a custom value from a packing slip to the SalesEditLines form's SalesParmTable), please let me know where you put your code.  

I appreciate any help! Thank you!

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Lily365,

    Can you explain us the business requirement?

    Usually, you can create a packing slip for multiple orders and multiple packing slips for a single order. By just looking at the SalesId, it would almost never give the correct result if you have multiple packing slips. How would you determine which packing slip is concerned for this invoice? Do you have scenarios where single invoices will be created for multiple packing slips? What MyField value should be used then?

  • Lily365 Profile Picture
    5 on at

    Hi,

    There will be one packing slip per invoice, and the packing slips will only be for one sales order. If there are several packing slips created for the same order, like in my example, the user shall select in the posting parameters the summary update for packing slip (and then click arrange) so that all packing slips are listed and visible, and then the user will select the one to be used.

    In the summary update for packing slip the MyField should be visible for all of the packing slips (SalesParmTables), that is what I am trying to achieve.

    Kind regards,

    Lily

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Lily,

    Thanks for the clarification. You mention that the user will select the correct packing slip on the update form. Instead of the while select statement you have now to loop all the packing slips for a sales order, you can select one record with a where clause on the packing slip ID. In that case, you retrieve only one record and you don't need the if statement which is currently having the type mismatch.

  • Lily365 Profile Picture
    5 on at

    Hi,

    Yes, and how would I get that packing slip ID? I have tried different ways since I posted this thread, but nothing is working because something is always null (SalesParmTable/SalesParmLine/SalesParmSubLine). Please, if you have done a similar customization, show me the code that made it happen!

    And to be clear: SalesParmTable.CustPackingSlipJour is never set in this process.

    One way I have tried to solve this is by copying the documentId method system code, from SalesParmTable.xpp (below).

        public display PackingSlipId packingSlipId(SalesParmTable _salesParmTable)
    
        {
    
            return this.documentId(_salesParmTable);
    
        }
     
    
      public Num documentId(SalesParmTable _salesParmTable)
    
        {
    
            SalesParmSubLine    salesParmSubLine;
    
            SalesParmLine       salesParmLine;
    
            Num                 documentId;
    
            NumberOfRecords     oneSubLines     = 1;
    
            NumberOfRecords     zeroSubLines    = 0;
    
     
    
            switch (SalesParmSubLine::subLinesTable(_salesParmTable))
    
            {
    
                case zeroSubLines:
    
                    // 
    
                    if (this.PackingSlipIdForUpdate_W)
    
                    {
    
                        documentId = "@SYS342615";
    
                    }
    
                    else
    
                    {
    
                        // 
    
                       documentId = '';
    
                        // 
    
                    }
    
                    // 
    
                    break;
    
     
    
                case oneSubLines:
    
                    select firstonly DocumentId from salesParmSubLine
    
                        exists join salesParmLine
    
                        where salesParmSubLine.LineRefRecId == salesParmLine.RecId
    
                           && salesParmLine.ParmId          == _salesParmTable.ParmId
    
                           && salesParmLine.TableRefId      == _salesParmTable.TableRefId;
    
     
    
                    documentId = salesParmSubLine.DocumentId;
    
                    break;
    
     
    
                default:
    
                    documentId = "@SYS342615"; //More than one journal line attached to the parm line
    
                    break;
    
            }
    
     
    
            return documentId;
    
        }
    
     

    The system puts the packingSlipId on SalesEditLines/SalesParmTable this way, with a display method. I tried using the documentId method code to get the packing slip id, like you suggest. I did it in the initFromSalesTable(SalesTable salesTable) method that I showed in my earlier post and also in the SalesParmTable_OnInitialized FormDataSourceEventHandler on the SalesEditLines form. But it doesn't find any SalesParmSubLines/SalesParmLines, so it just sets documentid to an empty string. Of course I may be in the wrong spot with my code. 

    Again, if you want to help, please show me code that works. Thank you! 

     

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Lily,

    I haven't done a similar customization before. You can use the Trace parser or debugger to check what is being executed when a user enters the packing slip ID. Then you would be able to find the best place to add your logic to set a value to your MyField. The form and relates classes are not the most easy one to interact with.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans