Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

QueryBuildDatasource is null

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: QueryBuildDatasource is null

    it works now, thank you very much John.

    have a nice day

  • Verified answer
    Zain Bokhari Profile Picture
    Zain Bokhari 3,208 on at
    RE: QueryBuildDatasource is null

    You can try this.

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: QueryBuildDatasource is null

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: QueryBuildDatasource is null

    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
    Community Member Microsoft Employee on at
    RE: QueryBuildDatasource is null

    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));

    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans