Just some simple topics about the SysOperation, which can however, be quite useful to people who are just starting the grasp the framework. Today, one way to display the values from the caller in the dialog.
What we are trying to do is if we are leaving from a selected record in a form, and open up a SysOperation dialog, we have to populate some dialog fields with values from the record.
The code speaks for itself (remember, the code below in written in the main method of the constructor). Also, observe how the contract and the controller are working together to get us what we need:
public static void main(Args _args)
{
ITRSysOpControllerA controllerA = new ITRSysOpControllerA();
ITRSysOpContractA contractA;
controllerA.parmClassName(classStr(ITRSysOpControllerA));
controllerA.parmMethodName(methodStr(ITRSysOpControllerA, executeOperation));
if (_args != null &&
_args.record() != null &&
_args.dataset() == tableNum(ITRParentA))
{
contractA = controllerA.getDataContractObject();
contractA.parmValue(_args.record().(fieldNum(ITRParentA, Value))); }
controllerA.startOperation();
}
You could make your code simpler and more readable with the "as" operator:
ReplyDeleteparentRec = args.record() as ITRParentA;
if (parentRec)
{
contractA.parmValue(parentRec.Value);
}
Hi Martin,
ReplyDeleteTrue, it's just that I didn't want to allocate a new variable in the example; however, the complexity of the code would indeed be reduced if we were to use the as operator.
Thanks.