Dynamics AX Blog - Posts from 2017 - Page 2
SysOperation Framework: Simple class construct with data providerThe 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; }
Serviceclass 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"); } |
SysOperation-Framework: Simple class constructThe following code shows a very simple class construct for the SysOperation framework. Without the Dataprovider and UIBuilder. Serviceclass TutorialSysOperationService extends SysOperationServiceBase { } The method runService() is the actual service method. By means of the attribute SysEntryPointAttribute we control here that no further authorization checks are necessary. [SysEntryPointAttribute(false)] public void runService() { info("Done"); }
Controllerclass TutorialSysOperationController extends SysOperationServiceController { } In the new()-method, we link the controller to the service class. void new() { super(); this.parmClassName(classStr(TutorialSysOperationService)); this.parmMethodName(methodStr(TutorialSysOperationService, runService)); } The main()-method is the classic entry point when the controller is called via a MenuItem. public static void main(Args _args) { TutorialSysOperationController controller; controller = new TutorialSysOperationController(); controller.parmArgs(_args); controller.parmExecutionMode(SysOperationExecutionMode::Synchronous); controller.startOperation(); } |
Create shared project by code, add objects and create groups for each object typeWith the help of the job shown here, you can create a shared project by code, add objects and group them into groups per object type. static void AddNodeToSharedProject(Args _args) { projectNode projectNode; TreeNode treeNode; ProjectName projectName = "MyProject"; #AOT #AOTExport void addTreeNodeToProjectNode(treeNode _treeNode) { TmpIdRef tmpIdRef; tmpIdRef.clear(); tmpIdRef.Name = SysTreeNode::getPath(_treeNode); tmpIdRef.Mode = SysTreeNode::path2ApplObjectType(tmpIdRef.Name); tmpIdRef.useMode = UtilFileType::Application; tmpIdRef.insert(); SysProjectFilterRunBase::addProjectNodes(tmpIdRef, projectNode); } projectNode = infolog.projectRootNode(); projectNode = projectNode.AOTfindChild(#expProjectShared); projectNode = projectNode.AOTfindChild(projectName); // Create shared project if neccessary if( !projectNode) { projectNode = SysTreeNode::createProject(projectName, ProjectSharedPrivate::ProjShared); } // Add objects (and create groups) treenode = TreeNode::findNode(#TablesPath+#AOTRootPath+tableid2name(tablenum(AccountingDistribution))); addTreeNodeToProjectNode(treenode); treenode = TreeNode::findNode(#TablesPath+#AOTRootPath+tableid2name(tablenum(VendGroup))); addTreeNodeToProjectNode(treenode); treenode = TreeNode::findNode(#ClassesPath+#AOTRootPath+classStr(PriceDisc)); addTreeNodeToProjectNode(treenode); } In the same way you can also create a private project, simply replace the occurrences of Shared by Private. The created project looks like this: |
|
|
|
|
|
|
In the following scenario, all records of a temporary table are to be passed to a SysOperation construct.
For that we need:
Controller