-->
I recently started to study SysOperation framework. It is the new way to perform the interactive batchable code execution. Compared to RunBaseBatch which had 12 overloads, it has quite few, mainly

  • new (where we specify which class's method to execute actually)
  • main (where we call the base class's startOperation() method)
  • \
Apart from these two, another method is a key method, the method mapped in the new() body which is called by the framework on the startOperation() framework method
  • customMethod (the method we map in the new() body, this method do not need to reside here, it can be any class;s method, sometimes its the controller method, better practice is to create a service class and place this method there)
The microsoft provided guide might be good for robots and androids, but I am a human and I raise question. There was no where mentioned how a controller class comes to know which contract class is ITS CONTRACT CLASS ?

There was no clue. Only wild or intellegent guesses. One guess was, does it go by the name ? Not possible, simply not a practice at all to follow. Then What ? I read the code hard ? How many places have we provided the reference of a data contract ??? 

Yes I got it, instantly I realized this cab only be the contract class parameter passed as argument in the method which was mapped to be called by the framework method, 'startOperation()'. And this is all done in the controller class's new() method body. For proof of concept, I performed a rawwxample at my local machine.

I created a simple controller and 2 ccontract classes one having 1 more argument than the other. The code for all the three classes are provided for our reference;


Controller Class
class MaqkControllerClass extends SysOperationServiceController
{
}


void new()
{
    super();

    this.parmClassName(classStr(MaqkControllerClass));
    this.parmMethodName(methodStr(MaqkControllerClass, maqkMethod1));
    this.parmDialogCaption('Basic SysOperation Sample');
}

public static void main(Args args)
{
    MaqkControllerClass operation;

    operation = new MaqkControllerClass();
    operation.startOperation();
}

// The Data Contract class passed as Parameter - Whatever class is passed here becomes the Data Contract class for this controller
public void maqkMethod1(MaqkContractClass2 _maqkContract)
{ 

    info(strFmt('SysOpSampleBasicController: %1, %2', _maqkContract.parmNumber(), _maqkContract.parmText()));
}
Contract class 1 - just 2 members, 1 string, 1 integer
[DataContractAttribute]
class MaqkContractClass
{
    str text;
    int number;
}

[DataMemberAttribute,
SysOperationLabelAttribute('Number Property'),
SysOperationHelpTextAttribute('Type some number >= 0'),
SysOperationDisplayOrderAttribute('2')]
public int parmNumber(int _number = number)
{
    number = _number;

    return number;
}

[DataMemberAttribute,
SysOperationLabelAttribute('Text Property'),
SysOperationHelpTextAttribute('Type some text'),
SysOperationDisplayOrderAttribute('1')]
public Description255 parmText(str _text = text)
{
    text = _text;

    return text;
}
2nd Contract class with 1 more text variable
[DataContractAttribute]
class MaqkCOntractClass2
{
    str text;
    int number;
    str text2;
}

[DataMemberAttribute,
SysOperationLabelAttribute('Number Property'),
SysOperationHelpTextAttribute('Type some number >= 0'),
SysOperationDisplayOrderAttribute('2')]
public int parmNumber(int _number = number)
{
    number = _number;

    return number;
}

[DataMemberAttribute,
SysOperationLabelAttribute('Text Property'),
SysOperationHelpTextAttribute('Type some text'),
SysOperationDisplayOrderAttribute('1')]
public Description255 parmText(str _text = text)
{
    text = _text;

    return text;
}

[DataMemberAttribute,
SysOperationLabelAttribute('Text Property 2'),
SysOperationHelpTextAttribute('Type some other text2'),
SysOperationDisplayOrderAttribute('1')]
public Description255 parmText2(str _text2 = text2)
{
    text2 = _text2;

    return text2;
}

Note the signature of the custom method (mapped to be called on startOperation() framework method). It is of the type of our data contract class, MaqkContractClass2. In my example, I sent the MaqkControllerClass2 class parameter. What rendered as dialog? See the following



Changing this parameter to MaqkContractClass loads different dialog, notice the difference of one dialo field less below;



Hence prooved :) Question arises, what if we give a class with no [DataContractAttribute] or [DataMember] parameter ? Answer is given below :)



and you can press the edit method to see the internal code of how the contract class is exactly associated with the controller class ;)



top