Use enum values and unbounded table fields in insert_recordset
insert_recordset is one the greatest enhancement in AX 2012 which allows us to insert records from one to another table in single client-server trip. This is an X++ SQL statement and is similar to update_recordset which i explained in my this post. Sometime we may require to insert values into destination table’s column which do not exists in source table’s column. To elaborate it more let’s have an example and then I will explain you how it works; static void testJob(Args _args) { ProjTable projTable, projTableInsert; ProjStatus enumValue = ProjStatus::Created; str 30 strValue = “test”; update_recordSet projTable Setting Name = “test” where projTable.projId == “Foobar”; insert_recordset projTableInsert (Name, ProjId) select strValue, ProjId from projTable where projTable.projId == “Foobar”; // You can set to an enum value, providing that update_recordSet projTable Setting status = ProjStatus::Created where projTable.projId == “Foobar”; insert_recordset projTableInsert (Status, ProjId) //select ProjStatus::Created, ProjId NOT ALLOWED select enumValue, ProjId from projTable where projTable.projId == “Foobar”; } I have two variables StrValue of string type and enumValue of enum (ProjStatus) type. You can set enum value directly into update_recordset but this is NOT ALLOWED in insert_recordset. For this reason I declared a variable enumValue and used later in insert_recordset statement. another complex example for insert_recordset; // I created this method to insert records into customized table (JobProfitDetailsSw) from different tables. private void insertPurchaseOrderTypeProjCostTrans(ProjId _projId) { JobProfitDetailsSW jobProfitDetailsSW; ProjCostTrans projCostTrans; VendInvoiceJour vendInvoiceJour; str 20 jobProfitSourceSw = enum2str(JobProfitSourceSw::BCIInvoice); str 20 jobProfitTypeSw = enum2str(JobProfitTypeSw::Cost); insert_recordset jobProfitDetailsSW (Amount, Description, JobProfitSourceStr, JobProfitTypeStr, ProjectDate, ProjId, CategoryId) select sum(TotalCostAmountCur), Txt, jobProfitSourceSw, jobProfitTypeSw, AsOfDate, _projId, CategoryId from projCostTrans group by Txt, projId, CategoryId where projCostTrans.TransDate <= AsOfDate && projCostTrans.TransactionOrigin == ProjOrigin::PurchaseOrder && projCostTrans.ProjId == _projId join vendInvoiceJour group by Purchid where vendInvoiceJour.LedgerVoucher == projCostTrans.VoucherJournal; }
All about Update_recordset
AX 2012 introduces many feature in regards to the performance enhancement and provides ways to access (insert, delete, update) database with less overhead (less database calls). If we talk about updating record(s) in database, few points come into our mind. One is looping through all records and update them in database (will create total number of records calls to database, and will degrade performance). How about to make only one call to database and update all records in this one call. AX 2012 provides way to use X++ SQL statements to enhance performance. This option is update_recordset which enables you to update multiple rows in a single trip to the server. SQL server statement UPDATE CUSTTABLE SET BLOCKED = 0 WHERE CUSTTABLE.ACCOUNTNUM = ”; X++ SQL Server static void update_recordSetJob(Args _args) { CustTable custTable; // Table buffer declaration update_recordSet custTable setting Blocked = 0 where custTable.AccountNum == “”; } We can also use join statements in update_recordset update_recordSet custTable setting Blocked = 0 Join custTrans where custTable.AccountNum == custTrans.AccountNum && […some other criteria];
Cache display methods in AX 2012
Display methods must be written at the table level However, developers often write display or edit methods to perform some calculations and then bind them on form’s controls to allow user to display or edit values in those bounded controls. Display/Edit methods create excessive client-server round trips and impact on product performance. And if there are display methods added on the form it will make 5 client-server round trips, one for each method. Options 1: CacheAddMethod This issue can be addressed by using the CacheAddMethod on the FormDataSource. This method enables the form to calculate all of the display methods in single round trip to the server rather making individual calls. Let’s assume you have added edit method on ProjTable form to show some calcuated dates. Override init() method under ProjTable datasource and write following code; public void init() { super(); ProjTable_ds.cacheAddMethod(tableMethodStr(ProjTable, projectCompletedDate), false); } Options 2: SysClientCacheDataMethodAttribute AX2012 also allows to use SysClientCacheDataMethodAttribute attribute in the display method declaration. Then, forms should cache such methods automatically.Attribute’s constructor accept one optional parameter (_updateOnWrite), which corresponds to the second parameter of cacheAddMethod().Example: [SysClientCacheDataMethodAttribute(true)] display DirPartyType type() {…} [SysClientCacheDataMethodAttribute] public display EcoResProductTitle title() { return inventTable.product().title(); } Options 3: CacheDataMethod peoperty on Form’s control AX 2012 introduces a new feature called the Declarative Display caching. This allows you to enable caching by setting the form control property CacheDataMethod with either of three values; Yes, No and Auto A lot more on this topic is here https://msdn.microsoft.com/en-us/library/aa596691.aspx Happy Daxure!ing
“An item with the same key has already been added” in SSRS report
“An item with the same key has already been added” You may encounter this error while creating SSRS report and the reason behind this error is having fields with the same name in the query used in report. To deal with this issue, in AX go to the query used in report and identify the fields that are duplicated between the datasources in the query. Delete overlap field by setting the Dynamic property to NO at fields node of the datasource in query. Happy Daxure!ing
Unable to find appropriate service endpoint information in the configuration object Dynamics Ax 2012
“Unable to find appropriate service endpoint information in the configuration object Dynamics Ax 2012” There can be multiple reasons to see this error while working on SSRS report in AX 2012. SSRS reports and AOS services communicate via WCF services and these WCF services are either not running on AOS or need to refresh under AX client configuration. First would be, BIServices is not activated under System Administration > Setup > Services and Application Integration Framework > Inbound ports. Second option to resolve this error is to refresh WCF configuration under Connection tab of Dynamics AX Client Configuration. This configuration file contains WSDL Port which is used to talk BIServices as shown above. If BIServices are activated in first step then import your AX configuration file into AX Configuration Utility and press Refresh Configuration button. Happy Daxture!ng
Fiscal calendar period dates and status
Financial calendars can be created and accessed from General ledger > Setup > Financial calendars. Fiscal calendar periods status (Open, On hold and Closed) can be changed from General ledger > Setup > Ledger > button. Following job can be used to get Start and End date of current Fiscal year static void fiscalCalendarDates(Args _args) { PeriodStart periodStartDate; PeriodEnd periodEndDate; periodStartDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).StartDate; periodEndDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).EndDate; info(strFmt(“%1”, periodStartDate)); info(strFmt(“%1”, periodEndDate)); periodStartDate = FiscalCalendars::findFirstDayofYear(Ledger::find(Ledger::current()).FiscalCalendar, systemDateGet()); periodEndDate = FiscalCalendars::findLastDayofYear(Ledger::find(Ledger::current()).FiscalCalendar, systemDateGet()); info(strFmt(“%1”, periodStartDate)); info(strFmt(“%1”, periodEndDate)); } Following job can be used to get the period status (Open, On hold and Closed) static void checkFiscalCalendarPeriod(Args _args) { TransDate transDate = systemDateGet(); RecId calendarRecId; FiscalCalendarPeriod fiscalCalendarPeriod; calendarRecId = Ledger::fiscalCalendar(CompanyInfo::find().RecId); fiscalCalendarPeriod = FiscalCalendars::findPeriodByPeriodCodeDate(calendarRecId, transDate, FiscalPeriodType::Operating); if (transDate) { if (! fiscalCalendarPeriod) { checkFailed(strFmt(“@SYS17614”,date2StrUsr(transDate, DateFlags::FormatAll))); } if (fiscalCalendarPeriod.currentLedgerPeriodStatus() != FiscalPeriodStatus::Open) { checkFailed(strFmt(“@SYS17615”, date2StrUsr(transDate, DateFlags::FormatAll))); } } }
Dynamics AX tab in MS Project Client
To open Dynamics AX project’s WBS structure in MS Project, Microsoft Dynamics Add-in for Microsoft Project must be installed. 1. Open MS Project 2. Create a new blanl project 3. Select the File menu option 4. Select options there and click Add-Ins. You should see “Microsoft Dynamics AX Add-in for Microsoft Project” If it is missed in the list of Active Application Add-Ins and is shown under Inactive Application Add-Ins list. You need to activate it. To activate it; Click on Go… A dialog will pop up and will let you select installed Add-Ins you want to activate. After following these steps you will be able to see Dynamics AX tab in MS Project file. Reference: http://blogs.technet.com/b/tompatton/archive/2013/12/12/troubleshooting-the-project-client-add-in.aspx
MS Project client integration with AX 2012
This post covers the integration of MS Project Client with MS Dynamics AX 2012 R2 CU7. Services setup in AX 2012 1. For the first time setup we have to deploy AifProjWBS service group from AOT in AX 2012 Project management and accounting parameters in AX 2012 2. Setup appropriate parameter for storing MS project files. In this example I am using Archive directory other option can be Sharepoint. 3. Folder path for Microsoft Project files to sit. It can be local directory path or UNC path. Please make sure UNC path must be accessible from the user you are logged-in in AX. Default project categories 4. On the Journal tab of the Project management and accounting parameter screen, specifiy the default category for Hour transaction type. Important: This is the category value that will be assigned to tasks when you sync with project file. Without this default value rows from Microsoft project file will not be imported into AX. Setup project in AX 2012 5. Create a new project and make sure to specify the calendar 6. Click on Open in Microsoft Project. 7. MS project file opens Optional: You can verify this file is generated in a path which you set in step 3. 8. Add new tasks here; in this example I have added “Sales” task and select default category “Hour” 9. Click on Publish; you will be notified by three options Publish New Project: You have to provide Project ID which will be imported into AX on sync Replace Existing Project: Be careful in selecting this option as it does exactly what it says. It REPLACES all activities in AX Save a template: This will create a new project template 10. On successful sync it will create/update the work breakdown structure for a project in AX 2012 11. You will notice yellow bar on top on WBS indicating that WBS is linked with MS project client and cannot be modified from AX client. 12. At the same time you can see another button “Unlink from Microsoft Project” is enable which will allow you to edit your WBS in AX but this will break the link between AX and the project file generated.
Saving and Selecting voucher templates in AX 2012
Since there are numerous options available in AX 2012 to create journal lines very quickly from already saved voucher templates. Someone can go with the option which best suites their requirements out of these available options; Voucher Template, Periodic Journal, Allocation Rules and Accrual Schema. This post is all about saving and selecting Voucher Template and here is how we can use this feature; 1. Under General ledger module > Journals > General journal form 2. Select a journal which you want to use as a source for Voucher Template 3. Click on Lines button to open journal lines 4. Click on Functionss > Save voucher template Window will pop up with either one of the two options for Template type to select; Percent or Amount Option Percent: Select the voucher template to use; click on OK and enter the amount of the general journal Option Amount: Select the voucher template to use; click on OK 5. Create a new general jounal and on general journal lines form click Functions > Select Voucher templates 6. It will show you Saved voucher templates which we did in step 3 7. Select appropriate voucher template and Click OK 8. All jounral lines of voucher template will be moved to new created geneal journal lines form Nice and easy option when we have to create several time the same journal lines and has been a most commonly used for long transactions.
Dynamics AX 2012 R3 System Requirements
Microsoft updated system requirements documents for AX 2012 R3 version and can be downloaded from http://www.microsoft.com/en-pk/download/details.aspx?id=11094

