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

Create One Pending Invoice for Multiple Packing Slip & Purchase Order

(3) ShareShare
ReportReport
Posted on by 89
Hi, I want to create one pending invoice for multiple Purchase Order & Product Receipt. I have called reArrange from PurchFormLetter with SumBy based on Invoice Account, but the invoices are still separated based on Purchase Order.
 
Purchformletter_invoice         Purchformletter;
vendPackingSlipJour             vendPackingSlipJour;
TmpFrmVirtual                   tmpFrmVirtual;
ParmId                          parmId;
VendInvoiceInfoTable            vendinvoiceinfoTable;
vendInvoiceInfoLine             vendInvoiceInfoLine;
List                            selectedList = new List(Types::Record);

while (productReceiptEnum.moveNext())
{
    tmpFrmVirtual.setTmp();
            
    // Add the packing slips into tmpFrmVirtual
    select firstonly vendpackingslipjour
        where vendpackingslipjour.RecId == productReceiptEnum.current()
        && vendPackingSlipJour.InvoiceAccount == _parm.parmVendAccount();

    tmpFrmVirtual.clear();
    tmpFrmVirtual.TableNum  = vendpackingslipjour.TableId;
    tmpFrmVirtual.RecordNo  = vendpackingslipjour.RecId;
    tmpFrmVirtual.NoYes     = NoYes::Yes;
    tmpFrmVirtual.Id        = vendpackingslipjour.PurchId;
    
    tmpFrmVirtual.insert();

    if (tmpFrmVirtual)
    {
        selectedList.addEnd(tmpFrmVirtual);
    }
}
        
// Construct form letter
Purchformletter = purchformletter::construct(DocumentStatus::Invoice);
        
// Add the packing slips to the purch form letter
Purchformletter.selectFromJournal(selectedList.pack());

purchformletter.parmNumber(_parm.parmInvoiceNum());
purchformletter.specQty(purchupdate::ReceiveNow);
purchformletter.sumBy(AccountOrder::Account);
purchformletter.reArrangeNow(true);
purchformletter.reArrange();

parmId = purchformletter.parmId();
        
//Edit the vendInvoiceInfo table if you need it , otherwise this code is not needed.
while select forupdate vendInvoiceInfoTable
    where vendinvoiceinfoTable.ParmId == parmId
{
    vendinvoiceinfoTable.Num = _parm.parmInvoiceNum();
    vendinvoiceinfoTable.VendInvoiceSaveStatus = VendInvoiceSaveStatus::Pending;
    vendInvoiceInfoTable.update();
}
 
I have the same question (0)
  • Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at
    Hi,

    Have you tried to debug the code to see what's going on? I think that would be the way to go.
  • AB-21051008-0 Profile Picture
    89 on at
    @Anton Venter I want to debug but it's a service class that run from API. I should move this code to another class and run manually, but I will try to debug

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans