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)

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

I have the same question (0)
  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

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

    community.dynamics.com/.../156928

  • Thomas Vogt Poulsen Profile Picture
    345 on at

    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
    Thomas Vogt Poulsen Profile Picture
    345 on at

    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.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans