How to modify existing query in AX 2012

Hi folks,

Today I am will be emphasizing on how to modify existing AOT queries.

Suppose we have a scenario where we want to add date range to existing AOT query which is through SysQuery Class.

First we need to attach datasource on which we are building range but we are not adding datasource. e.g.,

qbds = queryCopy.dataSourceTable(tableNum(Table));

We are adding ranging to existing query itself  but not to new will create new if you add this following statement.

qbds = queryCopy.adddataSource(tableNum(Table)); //this will create new query so this wont effect existing query. so, avoid this

qbds.addRange(fieldNum(table, field)).value(SysQuery::range(from,to));

if want to modify range which is through SysQuery Form, then you wont add range, you will modify existing range of existing query.  this will effect runtime.

qbds.rangeField(fieldnum(table, field)).value(SysQuery::range(from,to));

This is how you work on existing query. This is just a simple example, there are a lot of things you can learn on this.

you can also write as follows.

qbds.addRange(fieldNum(table, field)).value(queryRange(from,to));

Hope you understood.

Till then Happy DaXing………..,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: