Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

QUerystr returning blanks records too

Posted on by 425

I have created a aot query as DeliveryNotegroup which consists one table and I have selected 

querystr.png

static void Job203(Args _args)
{
Query q = new Query(queryStr (DeliveryNotegroup));
;

QueryRun qr;
QueryBuildDataSource qbd;
SON_AttachmentELMOInvoice SON_AttachmentELMOInvoice;
QueryBuildRange qbr;

qbd = q.addDataSource(TableNum(SON_AttachmentELMOInvoice));
qbr = qbd.addRange(FieldNum(SON_AttachmentELMOInvoice, SummaryInvoiceNumber));
qbr.value(("17620191"));
qr = new QueryRun(q);

while(qr.next())
{
SON_AttachmentELMOInvoice = qr.get(tableNum(SON_AttachmentELMOInvoice));
info(strFmt("%1",SON_AttachmentELMOInvoice.RecId));
}
}

actually in the AOT query I have only one table  if the table has 70 records when i run the while(qr.next())  it returns 70 records with their rec id  and  70 blanks records  so the query run runs for 140 times for 70 records 

I find one thing  find that when  create the dynamics query with querybuild without aot query it returns correct value. only 70 records  and which is correct 

*This post is locked for comments

  • rohit1900 Profile Picture
    rohit1900 425 on at
    RE: QUerystr returning blanks records too

    thank you Martin issue resolved.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: QUerystr returning blanks records too

    It seems that your intention was to add a range to the datasource defined in AOT, but that's not what your code does. You ignore the existing datasource and you create a new one (by addDataSource()) and you filter this new datasource.

    Use q.dataSourceTable() instead of q.addDataSource() to get the datasource defined in AOT.

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans