Introduction:
You can develop components / write business logic and later can be hosted as services on AOS with help of Windows communication foundation. These services later can be used by or integrated with the third party applications in order to communicate with Dynamics AX.
BOF Artifacts:
Data Contract Class:
By name only you can identify that this class is going to hold input parameters and query. In simple terms these are fields/controls which we add on ‘Dialog’ to get input from user like FromDate, query criteria’s through select button.
To identify class as Data Contract, we need to use [DataContractAttribute] as below,
And for parm methods, [DataMemberAttribute]
Note:Thumb rule, if you have 10 fields on ‘Dialog’ then you should have 10 parm method.
Service Operation Class:
This class contains main business logic for which you designed/create ‘Data Contract’ class.
UI Builder Class:
BOF automatically generates ‘Dialog UI’ based upon Data Contract class, but if we wanted to access dialog fields at run time for validations like ‘enabled/allowEdit/Lookup’ then we need to create separate class for user interface.
Let us follow below steps in order to create batch class without using ‘RunBaseBatch’ framework, instead we make use of new BOF framework.
Step1:
Create Data Contract class as below,
- [DataContractAttribute]
- class Tutorial_TestDataContract
- {
- TransDate transDate;
- CustAccount custAccount;
- }
For each variable, create parm method and add [DataMemberAttribute] as below,
- [DataMemberAttribute]
- public TransDate parmTransDate(TransDate _transDate = transDate)
- {
- transDate = _transDate;
- return transDate;
- }
//
- [DataMemberAttribute]
- public CustAccount parmCustAccount(CustAccount _custAccount = custAccount)
- {
- custAccount = _custAccount;
- return custAccount;
- }
Step 2:
Once you done with data contract class, create class to write business logic which will make use of above input parameters. It’s like ‘run’ method of any batch class where we write actual business logic.
- class Tutorial_TestBatchServiceOperation extends SysOperationServiceController
- {
- }
Create ‘new’ method as below
- public void new(identifierName _className = "", identifierName _methodName = "", SysOperationExecutionMode _executionMode = 0)
- {
- super();
- this.parmClassName(_className);
- this.parmMethodName(_methodName);
- this.parmExecutionMode(_executionMode);
- }
Create ‘Construct’ method as below
- public static Tutorial_TestBatchServiceOperation construct()
- {
- ClassName className;
- MethodName runMethodName;
- SysOperationExecutionMode execMode = SysOperationExecutionMode::Synchronous;
- Tutorial_TestBatchServiceOperation testBatchServiceOp;
- className = classStr(Tutorial_TestBatchServiceOperation);
- runMethodName = methodStr(Tutorial_TestBatchServiceOperation, runMyLogic);
- testBatchServiceOp = new Tutorial_TestBatchServiceOperation(className,
- runmethodName,
- execMode);
- testBatchServiceOp.parmDialogCaption("Tutorial SysOperation Batch");
- return testBatchServiceOp;
- }
//Method which will act as entry point to your business logic
//You can compare this method to 'run' method of any class
- public void runMyLogic(Tutorial_TestDataContract _data)
- {
- ;
- info(strFmt("You entered %1, %2", _data.parmCustAccount(), _data.parmTransDate()));
- }
Finally main method to make class to run
- public static void main(Args args)
- {
- Tutorial_TestBatchServiceOperation testBatch;
- testBatch = Tutorial_TestBatchServiceOperation::construct();
- testBatch.startOperation();
- }
Step3:
It’s very important to run ‘Incremental CIL Generation’ since above class will get executed on AOS.
Step4:
Run above class ‘Tutorial_TestBatchServiceOperation ‘ and you can see similar/familiar user interface for batch class
Click ‘Ok’ and you will get output as below
In next part will try to address how to access fields on dialog at run-time to control validations like ‘allowEdit/enabled’ etc….
Untill then ‘Happy Batching :) ‘
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.