Skip to main content

Posts

Create new legal entity in ax 2012 through code

I came across a scenario to create new legal entity in ax2012 through code, and wrote down following job to create legal entities. static void createLegalEntities(Args _args) {     CompanyInfo                         legalEntity;     DirPartyPostalAddressView           partyPostalAddressView;     int                                 coCount;     int                                 gap;     int      ...

Filter records in form by code

Courtesy: http://dynamics-ax-live.blogspot.com/2010/03/how-to-filter-records-in-form-by-code.html Step 1: Declare a class variable In the ClassDeclaration method of the form, define a range. QueryBuildRange CurrencyQBR; Step 2: Instantiate the new range. In the init method on the datasource of the form, you assign the range to a specific field (after the super call). public void init() { super(); CurrencyQBR = this.query().dataSourceName('CustTable').addRange(fieldnum(CustTable,Currency)); } Step 3: In the last step, you assign a value to the range. This is done in the executeQuery method on the same datasource of the form. Before the super call. Like this: public void executeQuery() { ; CurrencyQBR.value(queryvalue('USD')); super(); }

Maintaining Data Integrity [AX 2012]

Reference: http://msdn.microsoft.com/EN-US/library/aa672802.aspx   You can maintain database integrity by using one or more of the following features: A  DeleteAction  element maintains database consistency when a record is deleted. For more information about adding a  DeleteAction  element, see  How to: Create Delete Actions . The  ttsbegin ,  ttscommit , and  ttsabort  keywords ensure that all changes that are associated with a transaction are completed successfully. If the changes are not successfully completed, the transaction is aborted and the database is rolled back to the initial state. The  UnitofWork  class can simplify the task of modifying the data records in multiple tables within the scope of a single transaction. For more information, see  How to: Use the UnitOfWork Class to Manage Database Transactions .

SqlDictionary table

A very nice post on SQLDictionary table.. telling the information about all the tables created in AX. Courtesy: http://axnotes.blogspot.com/ If you run this query in SQL Mgmt Studio, you'll get a list of the tables in your AOT: SELECT * FROM SqlDictionary WHERE fieldid = 0 AND flags <> 1 ORDER BY name

Form Method calling Sequence in Dynamics AX

 Courtesy: http://msdaxerp.wordpress.com/category/forms/ This gives the information of method calls in the form level while           1. Opening the Form.           2. Creating/Updating/Deleting the record in the Form.           3. Closing the Form. Sequence of Methods calls while opening the Form Form — init () Form — Datasource — init () Form — run ()   Form — Datasource — execute Query () Form — Datasource — active () Sequence of Methods calls while closing the Form Form — canClose () Form — close () Sequence of Methods calls while creating the record in the Form Form — Datasource — create () Form — Datasource — initValue () Table — initValue () Form — Datasource — active () Sequence of Method calls while saving the record in the Form Form — Datasource — ValidateWrite () ...

How to design and call a form through X++ code

http://msdn.microsoft.com/en-us/library/formrun.control.aspx static void createForm(Args _args) { Args args; Form form; FormRun formRun; FormBuildDesign formBuildDesign; FormBuildDataSource formBuildDataSource; FormBuildGridControl formBuildGridControl; FormGridControl formGridControl; DictTable dictTable; int idx; int height; // Create the form header. form = new Form(); form.name("myForm"); // Add data sources to the form. dictTable = new DictTable(tableNum(custTable)); formBuildDataSource = form.addDataSource(dictTable.name()); formBuildDataSource.table(dictTable.id()); // Create the form design. formBuildDesign = form.addDesign('Design'); // Add a grid control. formBuildGridControl = formBuildDesign.addControl(FormControlType::Grid,'Grid'); idx = formBuildGridControl.id(); formBuildGridControl.addDataField(formBuildDataSource....