AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.05.2011, 20:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,626 / 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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
msdax: How to Specify Range Values on a Query in a AX SSRS Report - AX Support - Site Home - MSDN Blogs Blog bot DAX Blogs 0 31.03.2011 11:11
axaptafreak: Label for query range cannot be modified in AX 5.0 Blog bot DAX Blogs 0 30.08.2007 16:50
axaptafreak: Label for Query Range cannot be modified (still) Blog bot DAX Blogs 2 25.07.2007 10:09
Fred Shen: Date data type in Query Range Value Expression Blog bot DAX Blogs 0 28.10.2006 16:40
Как вытащить информацию о Range из Query raz DAX: База знаний и проекты 1 26.03.2004 11:10

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:20.