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!