Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

query object

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am using query object in class using report data provider, i want to insert in temp table but temp is empty using this code:

Query                             query;
QueryBuildDataSource   qbds;
QueryBuildRange           range;
QueryRun                      queryrun;

query=new Query();
qbds=query.addDataSource(tableNum(InventSalesOrderView));
range=qbds.addRange(fieldNum(InventSalesOrderView,createdBy1));
//range.value(creation_user);
queryrun=new QueryRun(query);
while (queryrun.next()){

inventTMP.dataAreaId=salesview.dataAreaId;
inventTMP.type="Sales Order";
inventTMP.type_id=salesview.SalesId;
inventTMP.packing_id=salesview.PackingSlipId;
inventTMP.item_id=salesview.ItemId;
inventTMP.item_name=salesview.Name;
inventTMP.qty=salesview.Qty;
inventTMP.invent_location=salesview.InventLocationId;
inventTMP.created_by=salesview.createdBy1;
inventTMP.created_date_time=salesview.createdDateTime1;
tinventTMP.ransaction_date=salesview.DeliveryDate;
this.insert_Tmp_Table();

}

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: query object

    i do not need user that use system but need created by that field in view, my code retrieve salesview data only for created by that determine in the range,

    the question is: contract class use with object query or not?

    and how object query work to determine the range.

  • Jonathan  Halland Profile Picture
    Jonathan Halland 11,306 on at
    RE: query object

    Hi Mostafe

    Using your code, you can do something along the following lines:

    range=qbds.addRange(fieldNum(InventSalesOrderView,createdBy1));

    range.value(curuserId())

    the key is using "curuserid()" function

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: query object

    Thanks for your replay,

    but i have a question that a query object treat with contract to get range from the user who run the report or it show select button to determine range without need of contract class or why this run.

  • Verified answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,306 on at
    RE: query object

    Hi Mustafa, you need to populate your salesview object within your while loop e.g.

    salesview = queryRun.get(tableNum(InventSalesOrderView));

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans