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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

query object

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

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

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

  • Community Member Profile Picture
    on at

    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.

  • Jonathan  Halland Profile Picture
    11,310 on at

    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
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans