Показать сообщение отдельно
Старый 13.12.2011, 22:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
Dates In An Extended Query Range
Источник: http://alexvoy.blogspot.com/2011/12/...ery-range.html
==============

Let's say we need to range all the BOM versions that are active as of today. For this purpose we can use an extended range in the query.

{
QueryBuildRange qbr;
;
if(!_args.record())
return;
// there is an active caller!
switch (_args.record().TableId)
{
case tablenum(InventTable):
inventTable = element.args().record();
this.query().dataSourceTable(tablenum(InventTable)).addRange(fieldnum(InventTable, ItemId)).value(inventTable.ItemId);
qbr = this.query().dataSourceTable(tablenum(BOMVersion)).addRange(fieldnum(BOMVersion, RecId));
qbr.value('(fromDate = '+date2StrXpp(today())+')');
break;
The final SQL query will look like this (a fragment):


= BOMVersion.ItemId AND ((Active = 1)) AND (((fromDate = 13\12\2011))) JOIN * FROM BOM(BOM_1) ORDER BY BOM.LineNum ASC ON BOMVersion.BOMId = BOM.BOMId
The idea was taken from the AX forum (in Russian).




Источник: http://alexvoy.blogspot.com/2011/12/...ery-range.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.