Тема
:
sumitsaxfactor: Using Methods Inside Query Range
Показать сообщение отдельно
05.05.2011, 20:12
#
1
Blog bot
Участник
25,643
/
848
(
80
)
Регистрация: 28.10.2006
sumitsaxfactor: Using Methods Inside Query Range
Источник:
http://sumitsaxfactor.wordpress.com/...e-query-range/
==============
This article may be a little late. I had discovered this long time back for one of the usages but writing it down now.
In class SysQueryRangeUtil you will find many static methods that can be used in a Range of a query.
Following are the methods that be used:
currentBusinessRelationsAccount
currentContactPersonId
currentCustomerAccount
currentEmployeeId
currentSessionDate
currentSessionDateTime
currentStaticMasterPlan
currentUserId
currentVendorAccount
dateRange
day
dayRange
greaterThanDate
lessThanDate
monthRange
yearRange
It is often useful to have these methods specially the methods involving dates. Think you have to set up a recurring batch job where you need to filter some records based on date criteria say all transactions having transactions today – 10. During such times these methods can be useful.
Here is one such example:
static void methodsInsideQueryRange(Args _args)
{
Query q = new Query();
QueryRun qr;
QueryBuildDataSource qbds;
str rangestr;
ProjTable p;
;
rangestr = ‘((Responsible == currentEmployeeId()) && (Responsible != ""))’;
qbds = q.addDataSource(tableNUm(ProjTable));
qbds.addRange(fieldNum(ProjTable, Responsible)).value(rangestr);
qr = new QueryRun(q);
while (qr.next())
{
p = qr.getNo(1);
info(p.ProjId);
}
info(q.dataSourceNo(1).toString());
}
This is how you use them in code. Now how is it useful in daily tasks?
Think of a scenario where you have 100’s of transactions posted daily and say you want to filter out those transactions that have been posted in last two months? How will you filter them?
Take all the transactions to excel and filter there?
Hold on there is a better way to do it in AX 2009.
On the required form press Ctrl + G and then in the filter use these methods:
Ex: (monthRange(-2,0)). This means we need to filter all those transactions starting from 2 months behind and till today. If we specify (monthRange(-2,2)), this means all the transactions between 2 months backward and 2 months forward.
Check the screen shots below:
Here is a screen shot of Item transactions form before applying monthRange:
After we apply the monthRange method filter:
Источник:
http://sumitsaxfactor.wordpress.com/...e-query-range/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите
личное сообщение
администратору.
Blog bot
Посмотреть профиль
Найти ещё сообщения от Blog bot