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)

Cannot chain call from Query object in X++

(0) ShareShare
ReportReport
Posted on by 510

Hi,

There is something particulary odd in AX2012 R2 CU9 (not tested in more recent versions) when we use Query object.

Consider the following example code:

new Query(queryStr(InventTable)).datasourceTable(tableNum(InventTable)).clearRanges();
(I used queryStr(...) to initialize the query but it could have been made using a packed query container or whatever)

This throws an exception "QueryBuildDataSource object not initialized". In order to resolve the issue, I have to explicitely store the query object in a new variable, like this:

Query    query = new Query(queryStr(InventTable));
query.datasourceTable(tableNum(InventTable)).clearRanges();

This way, the querybuilddatasource object is properly returned. The weird thing is, the first snippet of code works well in CIL context. It does not work in traditional X++ interpreter mode.

Actually, we found this while using the SysOperation framework,
we had some code pattern in our service class that looked like:

// Pseudo-code
public void process(_contract)
{
    _contract.getQuery().datasourceTable(tablenum(....
}

It was running pretty well in CIL until we wanted to test it in X++ by disabling CIL execution...

I can't really explain this difference in behavior, so if somebody from MS who knows kernel code can give us an explanation, he/she is welcome :)

Otherwise, maybe it can help some of us.

See you!

*This post is locked for comments

I have the same question (0)

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans