Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

query object

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

}

  • 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,304 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,304 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));

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,126 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans