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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Odd exception occurs trying to retrieve records from query

(0) ShareShare
ReportReport
Posted on by 30

Hi,

I have created an AX job to test an AX query. The query I'm trying to test is AxdPurchaseRequisition. Actually, I have disabled a number of datasources in the query. I only keep 3 data sources enabled.

  • VendPurchOrderJour
  • PurchTableAllVersions
  • PurchLineAllVersions

QueryDatasources.PNG

For these datasources the FetchMode propery is set to "1:n", the JoinMode property is set to "OuterJoin".

The job code looks like this

    Query q = new Query(queryStr(AxdPurchaseRequisition));
    QueryRun qr;
    Common vpoj;
    Common ptav;
    Common plav;

    QueryBuildDataSource qbds_vpoj;
    QueryBuildRange qbr_vpoj_purchid;

    qbds_vpoj = q.dataSourceName("VendPurchOrderJour");

    qbr_vpoj_purchid = qbds_vpoj.addRange(fieldNum(VendPurchOrderJour, PurchId));
    qbr_vpoj_purchid.value(queryValue("2100002142"));

    qr = new QueryRun(q);

    while (qr.next())
    {
        vpoj = qr.get(tableName2Id("VENDPURCHORDERJOUR"));
        ptav = qr.get(tableName2Id("PURCHTABLEALLVERSIONS"));
        plav = qr.get(tableName2Id("PURCHLINEALLVERSIONS"));

        info(strFmt("vpoj recid = %1 > ptav recid = %2 > plav recid = %3", vpoj.RecId, ptav.RecId, plav.RecId));
    }

When I run this code, an exception immediately occurs when following line of code is executed.

while (qr.next())

Cannot select a record in Purchase order confirmations (VendPurchOrderJour).

InMemory temporary tables must be the outer tables when they are joined to a TempDB table or permanent table.

I am not aware of any InMemory temporary table in this query.

What could be the problem here?

Thanks,

Frederiek

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Can't any of the joined tables be disabled by a configuration key?

    By the way, there is a better way for getting table ID. Use tableNum(VendPurchOrderJour) instead of tableName2Id("VENDPURCHORDERJOUR").

  • Frederiek Profile Picture
    30 on at

    It doesn't look like the problem would be security related. The error message appears after disabling the other data sources in the query. If all data sources in the query are enabled, the query runs without any error message.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    How exactly did you "disable" the data sources?

    Also, why don't you try to identify the problematic data source? Just knowing that it's related to unknown one of the disabled data sources isn't that useful. Then review where this data source is located (in the structure of the query).

  • Frederiek Profile Picture
    30 on at

    Data sources have the "Enabled" property. To disable the other data sources,  in the AOT, I set the Enabled property to "No" for each of those data sources.

    I am currently unable to reproduce the problem. The query has been modified, and potentially the problem was triggered by disabling one of the data sources which are currently not included in the query. I will see if I ever run into this problem again. If so, I might update this thread.

    Thanks

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    It sounds like if you disabled a parent of an enabled data source.

  • Frederiek Profile Picture
    30 on at

    Assuming that would have been the problem, then what does the tooltip text on the data source property Enabled mean?

    Specifies whether the data source (and all embedded data sources) should be ignored.

    I would think "embedded data sources" is referring to the child data sources. Or not?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Yes, probably.

    I would need to know what exactly you did to identify the actual cause. But it seems you don't need it anymore...

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans