web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

QueryBuildDatasource is null

(0) ShareShare
ReportReport
Posted on by

Hello,

i use this code for create QueryBuildDatasource, this code works on the SalesLine table :

static void Job47(Args _args)
{

    QueryRun                qr;
    QueryBuildDatasource    qbds;

    ;
    qr = new QueryRun("SalesLine");

    qbds = qr.query().dataSourceTable(tablenum(SalesLine));
    info("toto");
}

if i change by an other table, for example SalesTable this code doesn't work and qbds is null.
i don't uderstand why ?
somebody can help me please. thank you in advance.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    thank you for your answer John.

    in fact, i would like to read all data in InventTransferTable with the input parameters (fromDate_Period1,toDate_Period1,...) and add range. But the qbds is alway null, i don't know why ?

    if i change InventTransferTable  by SalesLine the code below works :

    qr = new QueryRun("InventTransferTable");

    qbds = qr.query().dataSourceTable(tablenum(InventTransferTable));

    qbdrInventTransferStatus = qbds.addRange(fieldnum(InventTransferTable,TransferStatus));

    qbdrSalesStatus.value(queryValue(InventTransferStatus::Created));

    qbdrShipDate = qbds.addRange(fieldnum(InventTransferTable,ShipDate));

    if (fromDate_Period1 || toDate_Period1)

    {

           qbdrShipDate.value(SysQuery::Range(fromDate_Period1, toDate_Period1));

    }

    else

    {

           qbdrShipDate.value(SysQuery::valueUnlimited());

    }

    if(myGplELCCarrierName!="")

    {

           qbdrGPLELCCarrierName = qbds.addRange(fieldnum(InventTransferTable,GPLELCCarrierName));

           qbdrGPLELCCarrierName.value(queryValue(myGplELCCarrierName));

    }

    while(qr.next())

    {

       myInventTransferTable = qr.get(TableNum(InventTransferTable));

    }

  • Community Member Profile Picture
    on at

    if i change in your code 'SalesLine' by 'InventTransferTable' i have this error : The query InventTransferTable does not exist.

    below the code :

    static void Job47(Args _args)

    {

       Query                   query = new Query();

       QueryRun                qr;

       InventTransferTable     inventTransferTable;

       ;

       query.addBaseQuery('InventTransferTable');

       qr = new QueryRun(query);

       while (qr.next())

       {

           inventTransferTable = qr.get(tableNum(InventTransferTable));

           info(inventTransferTable.TransferId);

       }

    }

  • Community Member Profile Picture
    on at

    oups, i forgot to create a query for InventTransferTable :-)

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    You can try this.

    SysQuery qr = new Query(queryStr(SalesLine)); //replace SalesLine with the name of your AOT query

  • Community Member Profile Picture
    on at

    it works now, thank you very much John.

    have a nice day

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans