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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans