Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Posting project item requirement picking list in X++

(0) ShareShare
ReportReport
Posted on by 345

Hi all

I am trying to do same functionality as if choosing Project > Item Requirement > Posting > Picking List from X++ of course without having a dialog popping up. I have several SOs that is posted in batch from a class.

I have found a couple of blogs that seems to be sharing the solution, but none of them is working for me.

Right now I have to methods that I hoped would work from looking at blog solutions, but have not had any luck yet.

private void postCreateAndPostJournal(SalesTable   _salesTable)

{

   SalesFormLetter_PickingList     salesFormLetter;

 

   salesFormLetter = SalesFormLetter_PickingList::newPickingList();

   salesFormLetter.updatePrinterSettingsFormLetter(pickingListPrinterSettings);

   salesFormLetter.createFromLines(true);

   salesFormLetter.update(

                   _salesTable,

                   systemDateGet(),

                   SalesUpdate::All,

                   AccountOrder::None,

                   NoYes::No,

                   NoYes::No,

                   NoYes::No,

                   NoYes::No);

}

private void postCreateAndPostJournal_2(SalesTable   _salesTable)

{

   SalesFormLetter_PickingList     salesFormLetter;

 

   Query                           query;

   QueryRun                       queryRun;

   QueryBuildDataSource           qbds;

 

   query = new Query(QueryStr(SalesUpdate));

   qbds = query.dataSourceTable(tableNum(SalesLine));

 

   // Build query range to find those lines which needs to be posted.

   qbds.addRange(fieldNum(SalesLine, SalesStatus)).value(queryValue(SalesStatus::Backorder));

   qbds.addRange(fieldNum(SalesLine,SalesId)).value(_salesTable.SalesId);

   qbds.addRange(fieldNum(SalesLine,SalesDeliverNow)).value('>0');

   queryRun = new queryRun(query);

 

   salesFormLetter = SalesFormLetter_PickingList::newPickingList();

   salesFormLetter.chooseLinesQuery(queryRun);

   salesFormLetter.specQty(SalesUpdate::DeliverNow);

 

   salesFormLetter.update(_salesTable);

}

If anyone has had experience or comments on this, it will be greatly appreciated.

Thanks

*This post is locked for comments

  • Verified answer
    RE: Posting project item requirement picking list in X++

    Just a side note running the code i CIL (Batch) actually fails with the error message "Unable to cast object of type 'Dynamics.Ax.Application.Query' to type 'Dynamics.Ax.Application.SysQuery'".

    So you need to change QueryRun to SysQueryRun and everything is fine.

  • RE: Posting project item requirement picking list in X++

    Hi guys,

    Thank you both for you quick answers.

    I got it working with Vilmos solution, but I still do not quite understand why mine and Sukruts code does not. It might be that being a SO with type ItemRequirement changes things a bit.

    But I am happy now.

    static void Job4(Args _args)

    {

       SalesFormLetter salesFormLetter;

       QueryRun queryRun;

       Query query;

       str strSalesTable = "SO425353";

       salesFormLetter = SalesFormLetter::construct(DocumentStatus::PickingList);

       query = new Query(QueryStr(SalesUpdate));

       query.dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable, SalesId)).value(strSalesTable);

       queryRun = new QueryRun(query);

       salesFormLetter.chooseLinesQuery(queryRun);

       salesFormLetter.transDate(systemdateget());

       salesFormLetter.specQty(SalesUpdate::All);

       salesFormLetter.printFormLetter(false);

       salesFormLetter.chooseLines(false,true);

       salesFormLetter.reArrangeNow(true);

       salesFormLetter.run();

    }

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Posting project item requirement picking list in X++

    You seem to be missing a couple of necessary calls, like chooseLines(). Have a look at this example:

    community.dynamics.com/.../156928

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans