Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:26:08+00:00 2026-06-03T01:26:08+00:00

I have the following code which builds a query on the Req Trans table

  • 0

I have the following code which builds a query on the Req Trans table to show me consolidated quantities by Item/Site;

query = new Query();
dsReqTrans = query.addDataSource(tablenum(ReqTrans));

dsReqTrans.addRange(fieldnum(ReqTrans, ReqPlanId)).value(_reqPlanId);
dsReqTrans.addRange(fieldnum(ReqTrans, RefType)).value(enum2str(_reqRefType));

dsReqTrans.addGroupByField(fieldnum(ReqTrans, ItemId));
dsReqTrans.addSelectionField(fieldnum(ReqTrans, Qty),  SelectionField::Sum);

dsInventDim = dsReqTrans.addDataSource(tablenum(InventDim));
dsInventDim.joinMode(JoinMode::InnerJoin);
dsInventDim.relations(false);
dsInventDim.addLink(fieldnum(ReqTrans, CovInventDimId), fieldnum(InventDim, InventDimId));

dsInventDim.addGroupByField(fieldnum(InventDim, InventSizeId));
dsInventDim.addGroupByField(fieldnum(InventDim, InventSiteId));

rangeInventSiteId = dsInventDim.addRange(fieldnum(InventDim, InventSiteId));
rangeInventSiteId.value(_parmSiteId);

This works very well. I get the sum of the qty column by item/site.

However, if I want to also add a range on ItemGroupId. For this i need to link to the InventTable like so;

dsInventTable = dsReqTrans.addDataSource(tablenum(InventTable));
dsInventTable.joinMode(JoinMode::InnerJoin);
dsInventTable.relations(false);
dsInventTable.addLink(fieldnum(ReqTrans, ItemId), fieldnum(InventTable, ItemId));

dsInventTable.addRange(fieldnum(InventTable, ItemGroupId)).value(_parmItemGroupId);

When I add this data source, the link to InventDim is broken. I get a sum of all item qty for all sites grouped by item only, rather than grouped per item/site.

Why could this be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:26:09+00:00Added an answer on June 3, 2026 at 1:26 am

    Basically you cannot have two inner joins to the same data source (you can, but it will not work).

    If using AX 2012 you can add the InventTable data source to the InventDim instead:

    dsInventTable = dsInventDim.addDataSource(tablenum(InventTable));
    dsInventTable.joinMode(JoinMode::ExistsJoin);
    dsInventTable.relations(false);
    // OBS 3 arguments next:
    dsInventTable.addLink(fieldnum(ReqTrans, ItemId), fieldnum(InventTable, ItemId), dsReqTrans.name()); 
    dsInventTable.addRange(fieldnum(InventTable, ItemGroupId)).value(_parmItemGroupId);
    

    In earlier versions you put InventTable first (remember to group by one field from InventTable):

    query = new Query(); 
    dsInventTable = dsReqTrans.addDataSource(tablenum(InventTable)); 
    dsInventTable.addGroupByField(fieldnum(InventTable, ItemId)); // You have to group/sum something
    dsReqTrans = dsInventTable.addDataSource(tablenum(ReqTrans)); 
    dsReqTrans.joinMode(JoinMode::InnerJoin); 
    dsReqTrans.relations(false); 
    dsReqTrans.addLink(fieldnum(InventTable, ItemId).fieldnum(ReqTrans, ItemId));
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which builds a Generic List of Abc from a
I have the following code which builds a JQueryUI Dialog popup. $j('<div></div>') .html(message) .dialog({
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which
I'm trying to use opengl in C#. I have following code which fails with
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which throws an exception COM Exception was unhandled in
I have the following code which inserts multiple records into MySQL: foreach ($_POST AS
I have the following code which sometimes return as true and sometimes doesn't. Any
I have the following code which works just fine when the method is POST,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.