Posts

Action Pane in Form

Today I will provide you document in which I have mentioned how to add Action Pane control in Forms. Action Pane Control

Fast Tab Control in Form

Today I will provide you document in which I have mentioned how to use fast tab control in AX 2012. Fast Tab Control

How to use Joins in AX

Today I will demonstrate you that how to use various type of joins in AX. Exist Join static void selectExistsJoin(Args _args) { CarTable carTable; RentalTable rentalTable; ; while select carTable exists join rentalTable where rentalTable.CarId == carTable.CarId { info(strfmt("CarId %1 has a matching record in rentalTable", CarTable.CarId)); } } Not Exist Join static void selectNotExistsJoin(Args _args) { CarTable carTable; RentalTable rentalTable; ; while select carTable notexists join rentalTable where rentalTable.CarId == carTable.CarId { info(strfmt("CarId %1 does not has a matching record in rentalTable", CarTable.CarId)); } } Outer Join static void selectOuterJoin(Args _args) { CarTable carTable; RentalTable rentalTable; ; while select carTable outer join rentalTable where rentalTable.CarId == carTable.CarId { if (!rentalTable.RecId) info(strfmt("No rentals for the car with carId %1", carTable...

Like Operator in AX

Today I will demonstrate you that how to use Like Operator in AX. static void RelationalOperatorLike(Args _args) { str carBrand = "Toyota"; ; // use the * wildcard for zero or more characters if (carBrand like "Toy*") { info ("The car brand starts with 'Toy'"); } // use the ? wildcard for one character if (carBrand like "Toy??a") { info ("The car brand starts with 'Toy' and the last character is 'a'"); } }

How to Write Data in XML File

Today I will demonstrate you that how to write data in XML file in AX. static void WriteXml(Args _args) { XmlDocument xmlDoc; XmlElement xmlRoot; XmlElement xmlField; XmlElement xmlRecord; XMLWriter xmlWriter; CarTable carTable; DictTable dTable = new DictTable(tablenum(CarTable)); DictField dField; int i, fieldId; str value; #CarsXmlTags ; xmlDoc = XmlDocument::newBlank(); xmlRoot = xmlDoc.createElement(#CarRootNode); while select carTable { xmlRecord = xmlDoc.createElement(#CarRecords); for (i=1; i<=dTable.fieldCnt(); i++) { fieldId = dTable.fieldCnt2Id(i); dField = dTable.fieldObject(fieldId); if (dField.isSystem()) continue; xmlField = xmlDoc.createElement(dField.name()); switch (dField.baseType()) { case Types::Int64 : value = int642str(carTable.(fieldId)); break; case Types::Integer : value = int2str(carTable.(fieldId)); break; default : value = carTable.(fieldId); break; } xmlField.innerText(value); xmlRecord.appendChild(xmlField); } xmlRoot.appe...

How to Read Data from XML File

Today I will demonstrate you that how to read data from XML file in AX. static void ReadXml(Args _args) { XmlDocument xmlDoc; XmlElement xmlRoot; XmlElement xmlField; XmlElement xmlRecord; XmlNodeList xmlRecordList; XmlNodeList xmlFieldList; CarTable carTable; DictTable dTable = new DictTable(tablenum(CarTable)); int i, j, fieldId; #CarsXmlTags ; xmlDoc = new xmlDocument(); xmlDoc.load(@"c:\temp\cars.xml"); xmlRoot = xmlDoc.getNamedElement(#CarRootNode); xmlRecordList = xmlRoot.childNodes(); for (i=0; i<xmlRecordList.length(); i++) { carTable.clear(); xmlRecord = xmlRecordList.item(i); xmlFieldList = xmlRecord.childNodes(); for (j=0; j<xmlFieldList.length(); j++) { xmlField = xmlFieldList.item(j); carTable.(dTable.fieldName2Id(xmlField.name())) = xmlField.innerText(); } carTable.insert(); } }

How to write Data in Text File

Today I will demonstrate you that how to write data in text file by using TextIO class in AX. static server void WriteTextFile(Args _args) { TextIo file; FileName filename = @"c:\temp\cars.txt"; CarTable carTable; container con; FileIoPermission permission; #File ; try { permission = new FileIoPermission(filename, #io_write); permission.assert(); file = new TextIo(filename, #io_write); if (!file) throw Exception::Error; file.outRecordDelimiter(#delimiterCRLF); file.outFieldDelimiter(";"); while select carTable { con = connull(); con = conins(con, 1, carTable.CarId); con = conins(con, 2, carTable.CarBrand); con = conins(con, 3, carTable.Mileage); con = conins(con, 4, carTable.Model); con = conins(con, 5, carTable.ModelYear); file.writeExp(con); } } catch(Exception::Error) { error("You do not have access to write the file to the selected folder"); } CodeAccessPermission::revertAssert();   }