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 :
Microsoft Dynamics AX (Archived)

partial PO posting (line wise)

(0) ShareShare
ReportReport
Posted on by 439

Hi all,

I have a requirement     I have  one PO with 2 PO lines

PO : 00002541  and PO lines

line 1  itemA   qty(2)

line 2 itemB qty(3)

We have packed all the lines in the PO but want to invoice specific line say line number 1  

I tried this code but not working any other help will be appreciated.

my code "

static void partial_Invoice(Args _args)
{
PurchFormLetter PurchFormLetter;

PurchTable PurchTable;

date _ReceivedDate = systemDateGet();

PurchId _purchId = "00002541";

PurchLine purchLine;

;

PurchTable = PurchTable::find(_purchId,true);

ttsBegin;

select forUpdate * from purchLine where purchLine.PurchId == PurchTable.PurchId;
{

purchLine.PurchReceivedNow = 2;

purchLine.update();

}

ttsCommit;

purchFormLetter = purchFormLetter::construct(DocumentStatus::PackingSlip);

//Enum name is recorded, label is registered

//change enum on purchUpdate to change what value(s) are posted

PurchFormLetter.update(PurchTable,"test233",systemDateGet(), PurchUpdate::ReceiveNow,AccountOrder::None,NoYes::No,NoYes::No);


}

Thanks,

Rohit

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi rohit1900,

    Please refer to this thread discussing similar issue community.dynamics.com/.../264262

  • rohit1900 Profile Picture
    439 on at

    Hi

    I have modified my job as  given in the thread

       PurchFormLetter PurchFormLetter;

       PurchTable purchaseTable;

       date _ReceivedDate = systemDateGet();

       PurchId _purchId = "00002545";

       PurchLine purchLine;

       Query query;

       SysQueryRun chooseLinesQuery;

      ;

      purchaseTable = PurchTable::find(_purchId,true);

       select purchLine

           where   purchLine.PurchId == purchaseTable.PurchId              

           &&      purchLine.PurchStatus != PurchStatus::Canceled;

           {

               purchLine.selectForUpdate(true);

               purchLine.InventReceivedNow = purchLine.PurchQty;

               purchLine.PurchReceivedNow = purchLine.PurchQty;

               purchLine.update();

           }

       query = new Query(queryStr(PurchUpdate));//Query for the filter criteria

       query.dataSourceTable(tableNum(PurchTable)).addRange(fieldnum(PurchTable,PurchId)).value(queryValue(purchaseTable.PurchId));                

       query.dataSourceTable(tableNum(PurchLine)).addRange(fieldNum(PurchLine,PurchStatus)).value(queryValue(PurchStatus::Backorder));

       chooseLinesQuery = new SysQueryRun(query);      

       purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);

       ttsbegin;

       purchFormLetter.chooseLinesQuery(chooseLinesQuery);

       purchFormLetter.update( purchaseTable,'test',systemDateGet(),PurchUpdate::ReceiveNow,AccountOrder::None,false,false);

       ttscommit;    

    it gives error

    QueryBuildRange object not initialized.

    Stack trace

    (S)\Classes\PurchFormletterParmDataInvoice\adjustLinesQuery - line 85

    (S)\Classes\PurchFormletterParmDataInvoice\selectChooseLines - line 26

    (S)\Classes\formletterParmData\createData - line 47

    (S)\Classes\PurchFormletterParmDataInvoice\createData - line 3

    (S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServerIL - line 32

    (S)\Classes\DictClass\callStatic

    (S)\Classes\SysDictClass\invokeStaticMethod - line 26

    (S)\Classes\SysDictClass\invokeStaticMethodIL - line 39

    (S)\Classes\Global\runClassMethodIL - line 30

    (S)\Classes\PurchFormletterParmDataInvoice\chooseLinesServer - line 21

    (C)\Classes\PurchFormLetter_Invoice\chooseLinesServer - line 3

    (C)\Classes\PurchFormLetter\chooseLines - line 26

    (C)\Classes\PurchFormLetter_Invoice\chooseLines - line 10

    (C)\Classes\PurchFormLetter\update - line 46

    (C)\Jobs\_partialPOInvoice - line 32

    in my case all lines are packed and invoice only select line.

  • Mea_ Profile Picture
    60,286 on at

    Did you 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

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans