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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 02.01.2014, 22:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Pawan's Ax blog: How To Iterate all the fields of a table in Ax2012 using x++ code.
Источник: http://pawansaxblog.blogspot.com/201...-table-in.html
==============

In my recent implementation I was having one requirement in this I had to retrieve all the fields of a table and then on certain criteria I had to update these fields in another table. I could do this sing If-else condition but it requires lot of code. So I did it in a better way.

public void updateEstimatesFromCase()
{
CopyEstimates copyEstimates;
SysDictTable dictTable;
SysDictTable caseDictTable;
SysDictTable activityDictTable;
SysDictField dictField;
SysDictField caseDictField;
SysDictField activityDictField;
FieldId fieldId;
FieldId caseFieldId;
FieldId activityFieldId;
CaseDetailBase caseDetailBase = caseDetailBase::find(this.caseId());
CaseTimeEstimatesTable caseTimeEstimatesTable;
ActivityTimeEstimatesTable activityTimeEstimatesTable;
ActivityTimeEstimatesTable buffer;
;

select firstonly caseTimeEstimatesTable
where caseTimeEstimatesTable.CaseDetailBase == caseDetailBase.RecId;

select firstOnly activityTimeEstimatesTable
where activityTimeEstimatesTable.smmActivities == this.smmActivities;

buf2Buf(buffer,activityTimeEstimatesTable);
if (activityTimeEstimatesTable.RecId)
{
activityTimeEstimatesTable.selectForUpdate(true);
activityTimeEstimatesTable.update();
}
caseDictTable = new SysDictTable(caseTimeEstimatesTable.TableId);
dictTable = new SysDictTable(this.TableId);
fieldId = dictTable.fieldNext(0);


while (fieldId)
{
dictField = dictTable.fieldObject(fieldId);
if (dictField.isSql() && !dictField.isSystem())
{
activityTimeEstimatesTable.smmActivities = this.smmActivities;
if (this.(fieldId) && fieldId != fieldNum(copyEstimates, smmActivities))
{

caseFieldId = fieldName2id(tableNum(CaseTimeEstimatesTable),dictField.name());
activityFieldId = fieldName2id(tableNum(ActivityTimeEstimatesTable),dictField.name());
activityTimeEstimatesTable.(activityFieldId) = caseTimeEstimatesTable.(caseFieldId);
if (activityTimeEstimatesTable.RecId)
{
activityTimeEstimatesTable.selectForUpdate(true);
activityTimeEstimatesTable.update();
}
else
{
activityTimeEstimatesTable.insert();
}
}
}
fieldId = dictTable.fieldNext(fieldId);
}
}


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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Pawan's Ax blog: How To Flush label Files Using x++ code. Blog bot DAX Blogs 0 20.12.2013 16:11
Pawan's Ax blog: Code to copy data from one table to another even though the tables are different provided the field names are same. in Ax2012 Blog bot DAX Blogs 0 09.12.2013 00:14
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
emeadaxsupport: New Content for Microsoft Dynamics AX 2012 : October 2011 Blog bot DAX Blogs 0 27.10.2011 17:11
axhelper: Add Fields to a table, using code_not the AOT In Dynamics Ax Blog bot DAX Blogs 0 04.10.2010 11:05

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:11.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.