Creating your own query functions
Query functions are used in user queries. One of the issues they can solve is when submitting batch routines, where a query range would be based on the current date.
One such function is currentDate()
. This is used in a query range as (currentDate())
. The system sees the round brackets and knows to look for a query function. Whenever the query is executed, the system will use the current system date.
In prior editions of AX, we would add public static methods to the SysQueryRangeUtil
class. This would mean an over-layer and, consequently, Microsoft has provided a way to add new query functions without over-layering.
How to do it...
To create a query function, follow these steps:
- Create a new class in the project and name it
ConQueryRangeFunctions
. - To add a query function to the class, in this case, to get the current worker record ID, write the following lines of code:
[QueryRangeFunction] public static str CurrentWorkerNum() { RefRecId currentWorkerRecId...