Overview
The data contract is a class that is the parameter for the entry point to the class that performs the process. The SysOperation framework automatically creates a dialog from the data contract, which will use the EDTs in the contract to provide the label, and even drop-down lists based on the table reference on the EDT.
User interface
You can associate the data contract with the user dialog with the SysOperationContractProcessingAttribute
[
DataContractAttribute,
SysOperationAlwaysInitializeAttribute,
SysOperationContractProcessingAttribute(classStr(CustRecurrenceInvoiceUIBuilder))
]
class CustRecurrenceInvoiceDataContract implements SysOperationInitializable,SysOperationValidatableor with the SysOperationContractProcessing
[
DataContractAttribute,
SysOperationAlwaysInitializeAttribute,
SysOperationContractProcessing(classstr(CustRecurrenceInvoiceUIBuilder)
]
When you add the parm methods to the contract class the field will be added to the user dialog.
[
DataMemberAttribute,
SysOperationLabelAttribute(literalstr("@SYS318853")),
SysOperationHelpTextAttribute(literalstr("@SYS318854")),
SysOperationDisplayOrderAttribute('1')
]
public TransDate parmFromDate(TransDate _fromDate = fromDate)
{
fromDate
= _fromDate;
return fromDate;
}
[
DataMemberAttribute,
SysOperationGroupMemberAttribute(identifierStr(Statements)),
SysOperationControlVisibilityAttribute(false)
]
public RefRecID parmWorkOrderLineRecID(RefRecID
_lineRecID = lineRecID)
{
lineRecID
= _lineRecID;
return lineRecID;
}
From a technical perspective, data-contracts can implement different interface classes.
Class interfaces
SysOperationInitializable
The main goal of this interface is to implement the contract initialization. If you want to initialize the default parameters in run time before the UI interface is displayed to the user, you need to implement the SysOperationInitializable class.
class EAMWorkOrderAddNoteDescriptionContract implements SysOperationInitializable
In this case method "initialize" will be available and can be rewritten. This method is used to initialize variables within the data contract. However, this method is called if no user usage data is found.
public void initialize()
{
this.parmFromDate(DateTimeUtil::getSystemDate());
}
In case the method "initialize" must be called at any time you have to add the SysOperationAlwaysInitializeAttribute to your contract.
[
DataContractAttribute,
SysOperationAlwaysInitializeAttribute,
SysOperationContractProcessingAttribute(classStr(CustRecurrenceInvoiceUIBuilder))
]
class CustRecurrenceInvoiceDataContract
In addition, if you want to clean up the field value on the dialog, it is required to add the same SysOperationAlwaysInitializeAttribute attribute to the desired method:
[
DataMemberAttribute,
SysOperationAlwaysInitializeAttribute,
SysOperationLabelAttribute(literalstr("@SYS318853")),
SysOperationHelpTextAttribute(literalstr("@SYS318854")),
SysOperationDisplayOrderAttribute('1')
]
public TransDate parmFromDate(TransDate _fromDate = fromDate)
{
fromDate
= _fromDate;
return fromDate;
}
SysOperationValidatable
The main goal of the SysOperationValidatable interface is to implement the contract validation. It allows you to validate the values provided for the data contract. For example, when users enter the field value on the dialog and press the “OK” button the "validate" method of the data contract will be called.
From a code perspective, its implementation looks like:
class CustRecurrenceInvoiceDataContract implements SysOperationValidatable
In addition, you heed to override the "validate" method:
///
<summary>
/// Determines whether the parameters are
valid.
///
</summary>
///
<returns>
/// True when the parameters are valid;
otherwise, false.
///
</returns>
public boolean validate()
{
boolean ok = true;
// add your validation here
return ok;
}
SysPackable
The SysPackable interface implementation forces the data contract class to create the "pack" and "unpack" methods which means that we can do serialization on it, like pack and unpack the variables defined in the #CurrentList for the #CurrentVersion macro.
class EAMWorkOrderAddNoteDescriptionContract implements SysPackable
{
Int dummy;
#define.CurrentVersion(1)
#localmacro.CurrentList
dummy
#endmacro
}
public container pack()
{
return [#CurrentVersion, #CurrentList];
}
public boolean unpack(container _packedClass)
{
Version version = RunBase::getVersion(_packedClass);
boolean ret = true;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = _packedClass;
break;
default:
ret = false;
}
return ret;
}