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

PO Invoicing through code getting "The value "XXX" is not found in the map."

(0) ShareShare
ReportReport
Posted on by 230

Hi All

We have a scenario where we want to automate PO invoicing as soon as we do SO invoicing.

I am calling a PO invoicing code after SI posting but I am getting  "The value "CA07-001114323" is not found in the map."

I am getting the same error if I am using the "Generate intercompany Invoice" feature after sales invoice.

3644.sierrr.JPG

I tested the same in a job getting the same error.

public static void main(Args _args)
    {
        PurchFormLetter purchFormLetter;
        VendInvoiceInfoTable    vendInvoiceInfoTable;
        
        PurchTable      purchTable = PurchTable::find('PO000000004-CA07');// salesTableLoc.interCompanyPurchTable();
        Num num = 'I0000010S-CA14';
        ttsbegin;
        purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
        //purchFormLetter = PurchFormLetter_Invoice::newFromSavedInvoice(vendInvoiceInfoTable);
        //purchFormLetter.interCompanyVoucher(custInvcJour.LedgerVoucher);
        purchFormLetter.printFormLetter(NoYes::No);
        purchFormLetter.updatePurchParmTableNum(num);

        //VendInvoiceInfoTable::updateExpectedValuesAndMatchStatusForSession(purchFormLetter.parmId());
        purchFormLetter.update(purchtable,num,systemdateget());
        ttscommit;
        if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
        {
            info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
        }

    }

After debugging I could see the error was coming from line 6533 

7802.ww.JPG

I have the same question (0)
  • Verified answer
    Krishnendu Profile Picture
    230 on at

                purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
                purchFormLetter.interCompanyVoucher(custInvcJour.LedgerVoucher);
                purchFormLetter.printFormLetter(NoYes::No);
                purchFormLetter.reArrangeNow(false); ////this is added to fix the error
                purchFormLetter.update(purchtable,custInvcJour.InvoiceId,systemdateget());
    
                if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
                {
                    info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
                }

    After adding purchFormLetter.reArrangeNow(false); PO is getting invoiced.

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    moved to the d365 forum

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 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans