This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The code below is a simple class construct for the SysOperation framework.
Datacontract
[DataContractAttribute] public class TutorialSysOperationDataContract { CustAccount custAccount; }[DataMemberAttribute] public CustAccount parmCustAccount(CustAccount _custAccount = custAccount) { custAccount = _custAccount; return custAccount; }Service
class TutorialSysOperationService extends SysOperationServiceBase { }The method runService() is the actual service method. Using the SysEntryPointAttribute attribute, we control here that no further authorization checks are necessary.
[SysEntryPointAttribute(false)] public void runService(TutorialSysOperationDataContract _dataContract) { info("Done"); }Controller
class TutorialSysOperationController extends SysOperationServiceController { }In new() we link the controller to the service class.
void new() { super(); this.parmClassName(classStr(TutorialSysOperationService)); this.parmMethodName(methodStr(TutorialSysOperationService, runService)); }The main() is the classic entry point when the controller is called via a MenuItem.
In the example, we fill the DataContract with a fixed value at this point. Here, for example, you would use the args object to determine the caller and fill the DataContract accordingly.
public static void main(Args _args) { TutorialSysOperationController controller; TutorialSysOperationDataContract dataContract; controller = new TutorialSysOperationController(); controller.parmArgs(_args); controller.parmExecutionMode(SysOperationExecutionMode::Synchronous); // DataContract dataContract = controller.getDataContractObject(); if(dataContract is TutorialSysOperationDataContract) { dataContract.parmCustAccount("10001"); } controller.startOperation(); }