web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Extending SysOperation contracts with DataMemberAttribute

Eugen Glasow Profile Picture Eugen Glasow 6,359

Since January 2019, it has become possible to decorate new “parm” methods on extension classes with “DataMember” attributes. In other words, it is now feasible to add a new parameter onto a dialog window of a standard class, even if this class was implemented within the SysOperation framework.
This was enabled by the so-called “4th extension wave” in 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)
{
updateDeprInfo = _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:
SysOperationUI dialog

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 posed another challenge. As suggested by Mr. Dráb here, the class should be declared with the SysOperationInitializable interface, and amended by an initialize() method. However, if the original class did not implement SysOperationInitializable, your extension cannot do 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.


This was originally posted here.

Comments

*This post is locked for comments