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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.03.2020, 18:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
a33ik: Extend the packed list of standard class variables
Источник: http://daxonline.org/1682-extend-the...variables.html
==============

This topic shows how to extend the list of packable variables of the existing class which realize SysPackable interface or not, the class needs to have only pack and unpack methods.
For example, you want to extend the SrsPrintDestinationSettings class which have a pack and unpack method, but it did not realize SysPackable interface and add a new print setup for selecting Email Template.
The following example shows how to implement this scenario:[ExtensionOf(classStr(SrsPrintDestinationSettings))]public final class MySrsPrintDestinationSettings_Extension { private SysEmailSystemId emailTemplateId; #define.CurrentVersion(1) #localmacro.CurrentList emailTemplateId #endmacro public SrsReportEMailDataContract parmEMailContract(SrsReportEMailDataContract _emailContract) { next parmEMailContract(_emailContract); if(!emailContract.parmBody() && emailTemplateId) { SysEmailMessageTable sysEmailMessageTable = SysEmailMessageTable::find(emailTemplateId, CompanyInfo::languageId()); emailContract.parmBody(SysEmailMessage::stringExpand(sysEmailMessageTable.Mail, SysEmailMessage::createStandardPlaceholders())); } return emailContract; } [DataMemberAttribute] public SysEmailSystemId myParmEmailTemplateId(SysEmailSystemId _emailTemplateId = emailTemplateId) { emailTemplateId = _emailTemplateId; return emailTemplateId; } public container pack() { container packedClass = next pack(); return SysPackExtensions::appendExtension(packedClass, classStr(MySrsPrintDestinationSettings_Extension), this.packMyExtension()); } public boolean unpack(container _packedClass) { boolean result = next unpack(_packedClass); if (result) { container packedClassExtension = SysPackExtensions::findExtension(_packedClass, classStr(MySrsPrintDestinationSettings_Extension)); //Also unpack the extension if (!this.unpackMyExtension(packedClassExtension)) { result = false; } } return result; } private container packMyExtension() { return [#CurrentVersion, #CurrentList]; } private boolean unpackMyExtension(container _packedClass) { Integer version; if (typeOf(conPeek(_packedClass, 1)) == Types::Integer) { version = conPeek(_packedClass, 1); } else { version = RunBase::getVersion(_packedClass); } switch (version) { case #CurrentVersion: [version, #currentList] = _packedClass; break; default: return false; } return true; }}To avoid collisions with other eventual extensions, I followed these best practices:
  • Prefix members and methods. In the example, the prefix “my” is used. This practice is important because it helps prevent name clashes with other extensions and future versions of the augmented class.


If you want to extend the RunBase class, docs from MS shows how a RunBase class can be augmented end to end https://docs.microsoft.com/en-us/dyn...-runbase-class



Original post:https://daxdevblog.blogspot.com/2020...ard-class.html



Источник: http://daxonline.org/1682-extend-the...variables.html
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
goshoom: Class extensions Blog bot DAX Blogs 0 18.07.2016 17:11
german_nav_developer: Dynamics NAV 2013 R2 multi-tenancy – Viele Mieterinnen ohne Stress und Neid Blog bot Dynamics CRM: Blogs 0 30.12.2013 19:00
a33ik: MS CRM 2011: Import of marketing list members using standard import with small extensions Blog bot Dynamics CRM: Blogs 0 21.05.2012 20:11
german_nav_developer: Codepage und Multilinguale Dynamics NAV Installationen Blog bot Dynamics CRM: Blogs 0 05.06.2011 15:51
Kashperuk Ivan: List panels in Dynaics AX - a short description of SysListPanel class Blog bot DAX Blogs 1 21.10.2007 22:51
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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