02.03.2019, 22:16 | #1 |
Участник
|
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, напишите личное сообщение администратору. |
|
|
|