this.Query().dataSourceTable(tableNum(<Table>)).rangeField(fieldNum(<Table>,<Field>)).value();
Monday, July 23, 2018
Wednesday, July 18, 2018
Monday, July 9, 2018
To Get configured Account Structure Data from Dynamics AX
//Getting configured Account Structure Data from dynamics AX
static void DimensionHierarchy(Args _args)
{
DimensionHierarchyLevel dimHierarchyLevel;
DimensionAttribute dimAttribute;
DimensionConstraintNode dimConstraintNode;
DimensionConstraintNodeCriteria dimConstraintNodeCriteria;
DimensionHierarchy dimHierarchy;
str 60 _dimHierarchy = "<Account structure name>";
;
setPrefix("");
while select RecId from dimHierarchy
where dimHierarchy.Name == _dimHierarchy
join RecId from dimHierarchyLevel
where dimHierarchyLevel.DimensionHierarchy == dimHierarchy.RecId
join Name from dimAttribute
where dimAttribute.RecId == dimHierarchyLevel.DimensionAttribute
join RecId from dimConstraintNode
order by dimConstraintNode.Ordinal
where dimConstraintNode.DimensionHierarchyLevel == dimHierarchyLevel.RecId
join dimConstraintNodeCriteria
where dimConstraintNodeCriteria.DimensionConstraintNode == dimConstraintNode.RecId
{
info(strFmt("%1 | From- %2 | To- %3",
dimAttribute.Name,
dimConstraintNodeCriteria.RangeFrom,
dimConstraintNodeCriteria.RangeTo
));
}
}
Reference: https://sangeethwiki.blogspot.com/2017/10/ledger-and-default-dimension.html
static void DimensionHierarchy(Args _args)
{
DimensionHierarchyLevel dimHierarchyLevel;
DimensionAttribute dimAttribute;
DimensionConstraintNode dimConstraintNode;
DimensionConstraintNodeCriteria dimConstraintNodeCriteria;
DimensionHierarchy dimHierarchy;
str 60 _dimHierarchy = "<Account structure name>";
;
setPrefix("");
while select RecId from dimHierarchy
where dimHierarchy.Name == _dimHierarchy
join RecId from dimHierarchyLevel
where dimHierarchyLevel.DimensionHierarchy == dimHierarchy.RecId
join Name from dimAttribute
where dimAttribute.RecId == dimHierarchyLevel.DimensionAttribute
join RecId from dimConstraintNode
order by dimConstraintNode.Ordinal
where dimConstraintNode.DimensionHierarchyLevel == dimHierarchyLevel.RecId
join dimConstraintNodeCriteria
where dimConstraintNodeCriteria.DimensionConstraintNode == dimConstraintNode.RecId
{
info(strFmt("%1 | From- %2 | To- %3",
dimAttribute.Name,
dimConstraintNodeCriteria.RangeFrom,
dimConstraintNodeCriteria.RangeTo
));
}
}
Reference: https://sangeethwiki.blogspot.com/2017/10/ledger-and-default-dimension.html
Thursday, July 5, 2018
UNIT TEST CASE FRAMEWORK in Dynamics AX
Attributes:
•SysTestMethodAttribute (Applies: Method) - Indicates that a method is a unit test. •SysTestCheckInTestAttribute (Applies: Method or class) - Indicates the test is a check-in unit test. A check-in test is run when checking in code to a version control system to ensure a proper level of quality. •SysTestNonCheckInTestAttribute (Applies: Method) - Indicates the test is not a check-in test. •SysTestTargetAttribute(<name>,<type>)(Applies: class) - Indicates the application object that is being tested by the test case. Examples of tested objects are class, table, and form
Code:
Class1:
[SysTestTargetAttribute('Bid Management System',
UtilElementType::Class)] class BMSTest extends SysTestCase {
ClsBMS clsBMS; //Class for master bid management system }
Override setup methodpublic void setUp() { clsBMS = new ClsBMS("name");//Create an master bid management system instance touse in test casessuper(); }[SysTestMethodAttribute] void testBidName() { this.assertEquals("your name", clsBMS.name());//Verify that the bid supplier name is set correctly}Class2:class ClsBMS { Name name; }Public void new(Name _name) { name = _name; }public Name name() { // Return the expected string. return name; }Compile both classRun a test case/AOT/Class/BMSTest/ Right click (Add-ins) and click run testsRefer:https://community.dynamics.com/ax/b/goshoom/archive/2015/09/07/unit-testing-in-ax-basicsReference content:http://codingchamp.blogspot.com/2012/10/unit-test-framework-in-microsoft.htmlThe Unit Test framework is tightly integrated into the MorphX IDE ofMicrosoft Dynamics AX. This integration is very importantto test-driven development (TDD) because a unit test can be created alongsidethe feature code it is testing. What is a Unit Test: A unit test is code that verifies that feature code has been implemented correctly. If you adhere to the principles of TDD, it is best for the developer who is writing the feature code to first write the unit tests. This puts emphasis on how feature code is consumed and creates a more user friendly application programming interface (API). A unit test, in the context of the Unit Test framework, includes test cases, how test cases are staged with data, and the organization of test cases. A test case is a class that extends the SysTestCase Class class. You can add test methods to test each requirement of the feature code. You should execute test cases when code is changed. Some Important Points: Every test case class should extend SysTestCase Class. For testing purpose you can write multiple methods for single actual method in code. For Classes their should only one class for testing a single class. Name the test class same as the class followed by test in the end. Name of the method in the test class should also contains test in the start. We write Unit Test for classes and tables only. Always Testing will be done on Blank Database. The attribute that must be placed on the unit test case class is: [SysTestTargetAttribute('SysDictTable',UtilElementType::Class)] The attribute that must be placed above the method of the test case is: [SysTestMethodAttribute] Methods for Setting Data: Two types of methods are use for setting up data.These are: 1. Setup Method. 2 Setup Test Case Method. 1.Setup Method: Setup Method runs before every Test method.For some times we usaually want fresh data so we write code in setup method.It works like this:First setup method executed than test method executed than tear down method executed than again setup method executed with fresh data than second test method executed and so on. 2.Setup Test Case Method: Setup Test case method runs only one time when test class is executed.In case of setup test case method it executed only one time and than tear down method for setup test case method will execute in the end. note:Due to some issues we usually dont use i.e override setup test case method we only use setup method. Tear Down Method: Tear Down method is basically use to flush out data.We normally dont override this method.It manages Automatically. A test method will typically contain several assertions that are required to hold true,for the test to be successful. Note: The use of the assertEquals method.This method,and other assert methods,are available as part of the SysTestCase framework.These methods also have an optional string parameter called _message,to specify the message that would go into the infolog.If the assertion fails.The following is list of available methods:
Sample XPO:
https://1drv.ms/f/s!Asi_SJ2dXQ3BqFIfQV_E3dK6VxHm
Tuesday, July 3, 2018
Get Lines of code modified in util Level Layer AX 2012
//Get Lines of code modified in util Layer
static void getCodeLinesByObjectsInAOT(Args _args)
{
#File
#AOT
TreeNode treeNode;
UtilElements utilElements;
container getObjectName;
SysScannerClass scanner;
int i;
int getLinesCount;
;
while select utilElements
where utilElements.recordType == UtilElementType::Table
//&& utilElements.utilLevel == UtilEntryLevel::CUS
&& utilElements.name == 'InventTable'
{
getObjectName += [utilElements.name];
}
//CUS code
for (i = 1; i <= conLen(getObjectName); i++)
{
treeNode = infolog.findNode(#TablesPath + #AOTDelimiter + conPeek(getObjectName, i) + #AOTDelimiter +'Methods' );
treeNode = SysTreeNode::nodeInLayer(treeNode,UtilEntryLevel::CUS);
treeNode = treeNode.AOTfirstChild();
while (treeNode)
{
if (treeNode.getNodeInLayer(UtilEntryLevel::CUS))
{
scanner = new SysScannerClass(treeNode);
getLinesCount += scanner.lines();
}
treeNode = treeNode.AOTnextSibling();
}
}
}
static void getCodeLinesByObjectsInAOT(Args _args)
{
#File
#AOT
TreeNode treeNode;
UtilElements utilElements;
container getObjectName;
SysScannerClass scanner;
int i;
int getLinesCount;
;
while select utilElements
where utilElements.recordType == UtilElementType::Table
//&& utilElements.utilLevel == UtilEntryLevel::CUS
&& utilElements.name == 'InventTable'
{
getObjectName += [utilElements.name];
}
//CUS code
for (i = 1; i <= conLen(getObjectName); i++)
{
treeNode = infolog.findNode(#TablesPath + #AOTDelimiter + conPeek(getObjectName, i) + #AOTDelimiter +'Methods' );
treeNode = SysTreeNode::nodeInLayer(treeNode,UtilEntryLevel::CUS);
treeNode = treeNode.AOTfirstChild();
while (treeNode)
{
if (treeNode.getNodeInLayer(UtilEntryLevel::CUS))
{
scanner = new SysScannerClass(treeNode);
getLinesCount += scanner.lines();
}
treeNode = treeNode.AOTnextSibling();
}
}
}
Subscribe to:
Posts (Atom)
Copy Markup charges while posting purchase invoice using X++
Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference. New class => Duplicate...
-
Restore .bacpac file to Development VM Steps: 1. Take Backup of AxDB database from Development VM 2. Open Command Pr...
-
Posting Vendor invoice based on Product receipt public void postPurchaseInvoiceJournal() { VendPackingSlipJour vendP...
-
Code for reserve and unreserved sales order lines Inputs : SalesLine, InventDim (Combination to reserve), Qty Note : To Reserve -> Pass...