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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 02.03.2019, 22:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
erconsult: Extending SysOperation contracts with DataMemberAttribute
Источник: http://erconsult.eu/blog/extending-s...mberattribute/
==============

Since January 2019, it has become possible to decorate “RunBase” classes implemented within the SysOperation framework with “DataMember” attributes, i.e. to add new parameters into the dialog window.
This was enabled with the so-called “4th extension wave” in the Platform update 23.

Before PU 23, the below code

[ExtensionOf(ClassStr(AssetRollForwardContract))]
final class AssetRollForwardContract_Extension
{
private boolean updateDeprInfo;
[DataMemberAttribute(identifierStr(AssetAdditionalAcqDepreciation))]
public boolean parmUpdateDeprInfo(boolean _updateDeprInfo = updateDeprInfo)
{
updateDeprnInfo = _updateDeprInfo;
return updateDeprInfo;
}
}
did not compile but brought up the error message “DataMemberAttributeOnExtensionClassNotSupported: The DataMemberAttribute is not supported on extension classes.

Now it works, and the new parameter is plugged in nicely at the desired place:


I met a few obstacles, though. As you extend the UI builders, add new classes, other programming artifacts, the parameters tend to disappear. Re-building the solution, re-building the whole model, deleting the usage data – nothing helps. This might be an issue in the compiler, as the only way to restore the UI was to delete and re-create the extension class.

Initializing the parameters with default values poses another issue. As suggested by Mr. Dráb here, the class must be decorated with the SysOperationInitializable interface, and amended by an initialize() method. However, if the original class was not implementing SysOperationInitializable, your extension cannot be any better.
The only solution that worked was simple as a brick: an inline assignment of the respective field variable (which is another feat in X++, quite a new one):

[ExtensionOf(ClassStr(AssetRollForwardContract))]
final class AssetRollForwardContract_Extension
{
private boolean updateDeprInfo = true;
[
DataMemberAttribute(identifierStr(AssetAdditionalAcqDepreciation)),
SysOperationLabelAttribute(literalstr("@SYS4080213")),
SysOperationHelpTextAttribute(literalstr("@SYS321607")),
SysOperationDisplayOrderAttribute('4')
]
public boolean parmUpdateDeprInfo(boolean _updateDeprInfo = updateDeprInfo)
{
updateDeprInfo = _updateDeprInfo;
return updateDeprInfo;
}
}

The parameter becomes active by default, but the last value selected by the user is still serialized and de-serialized nicely, right as it should be.

The post Extending SysOperation contracts with DataMemberAttribute appeared first on ER-Consult.



Источник: http://erconsult.eu/blog/extending-s...mberattribute/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
erconsult: Configuring Austrian and Norwegian per diems in Dynamics 365 Blog bot DAX Blogs 0 03.05.2018 04:28
erconsult: Exposing Dynamics 365 Onebox to the LAN Blog bot DAX Blogs 1 20.02.2018 05:12
erconsult: EU Tax directives Blog bot DAX Blogs 0 07.02.2018 05:20
erconsult: On provisions, accruals and deferrals Blog bot DAX Blogs 0 31.12.2017 16:24
stoneridgesoftware: Batch Processing in Dynamics AX 2012 Using SysOperation Framework Blog bot DAX Blogs 0 28.03.2017 00:11
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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