“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
Computed columns in Views – Dynamics AX 2012
Computed columns have been using in SQL server since many versions but this feature was available Dynamics AX since version 2012. Follow steps described here to learn how to create view and walthrough the complete example to understand how can we add computed columns in AX 2012 Views. More examples can be found from here; http://daxmusings.codecrib.com/2011/10/computed-view-columns-in-ax-2012.html Well, here is an example which illustrates how can we add computed columns in a view with different logic. Computed column; Returning Field in View public static server str compAmount() { #define.CompView(SWProjForecastCost) #define.CompDS(ProjForecastCost) #define.CostPrice(CostPrice) return SysComputedColumn::returnField(tableStr(#CompView), identifierStr(#CompDS), fieldStr(#CompDS, #CostPrice)); } Computed column; Converting UTC Date to Date in View public static server str compDate() { #define.CompView(SWProjForecastCost) #define.CompDS(ProjForecastCost) #define.ActualDateTime(ActualDateTime) str sDateTime; sDateTime = SysComputedColumn::returnField(tableStr(#CompView), identifierStr(#CompDS), fieldStr(#CompDS, #ActualDateTime)); return SysComputedColumn::fromUtcDateToDate(sDateTime); } Computed column; Returning Enum Value in View public static server str compGeneralTransType() { return SysComputedColumn::returnLiteral(Transaction::ProjectInvoice); } Computed column; Multiplying two coulmns and returning resultant from View private static server str compTotalCostPrice() { #define.CompView(SWProjForecastCost) #define.CompDS(ProjForecastCost) #define.QtyCol(Qty) #define.PriceCol(CostPrice) return SysComputedColumn::multiply( SysComputedColumn::returnField( tableStr(#CompView), identifierStr(#CompDS), fieldStr(#CompDS, #PriceCol) ), SysComputedColumn::returnField( tableStr(#CompView), identifierStr(#CompDS), fieldStr(#CompDS, #QtyCol) ) ); } Computed column; Case Statement in View public static server str TransType() { #define.CompDS(ProjForecastCost) #define.CompView(SWProjForecastCost) str ret; str ModelId = SysComputedColumn::returnField(identifierStr(SWProjForecastCost), identifierStr(ProjForecastCost), identifierStr(ModelId)); ret = “case ” + modelId + ” when ‘Sales’ then ‘Forecast Sales’ ” + ” when ‘Orders’ then ‘Forecast Orders’ ” + ” when ‘Latest’ then ‘Forecast Latest’ ” + ” end”; return ret; } Case Statement for this view looks like in SQL server as below; CASE T2.MODELID WHEN ‘Sales’ THEN ‘Forecast Sales’ WHEN ‘Orders’ THEN ‘Forecast Orders’ WHEN ‘Latest’ THEN ‘Forecast Latest’ END Till next post Happy Daxing 🙂
Retrieving/Picking files from Directory through X++
Following piece of code to pick all files from a directory. static void readFromDirectory(Args _args) { #Evat_NL #File // variable declration to retrieve files from folder Filename baseFolder; Filename pdfFilename; Filename foundBaseFileName; Filename foundFileName; container mainFolder, subFolder, fileContainer; boolean filesFoundMainFolder = true; boolean filesFoundSubFolder = true; int apiResult; int startTime, endTime, fileCounter; RecordInsertList recordList = null; int setCurrentFolder (Filename _filename = ”) { ; return WinAPI::setCurrentDirectory(_filename); } ; baseFolder = @”C:Testinvoices”; // Reading all pdf invoices from a directory apiResult = setCurrentFolder(SysTreeNode::duplicatePathDelimiters(baseFolder)); mainFolder = WinAPI::findFirstFile(“*.pdf*”); foundBaseFileName = conpeek(mainFolder, 2); startTime = WinAPI::getTickCount(); while (filesFoundMainFolder) { if (foundBaseFileName != #currentFolder && foundBaseFileName != #upFolder && foundBaseFileName != ”) { // Concatenating each file with base folder to get full path // For example; C:TestinvoicesInvoice1.pdf pdfFilename = baseFolder + foundBaseFileName; fileCounter++; } apiResult = setCurrentFolder(SysTreeNode::duplicatePathDelimiters(baseFolder)); foundBaseFileName = WinAPI::findNextFile(conpeek(mainFolder, 1)); filesFoundMainFolder = foundBaseFileName ? true : false; } endTime = WinAPI::getTickCount(); info(strFmt(‘It took %1 minutes to read %2 pdf files’, ((endTime – startTime)/1000)/60, fileCounter)); }
Tool to copy security permissions in AX
Copying security roles, groups, user options and associating worker against user The role based security works very well in AX 2012 and security development tool has also made the life of AX system administrator very charming. It was a nightmare to define security for each user in earlier versions of MS Dynamics AX. However, there is one area which security development tool does not cover and is often required in many occassions. That is “To Copy user roles from one user to another”. Let’s say we have created/imported a new user in AX and System Administrator requires to assign same role(s), existing users have, to this new added user. This requirement might come due to identical nature of work or responsibilities shared among different users. This tool will help you to copy users roles, users options, user groups, user’s main accounts and user association with worker by creating new worker if not exists. User association with worker is required to perform different business processes in AX, one of them is purchase requisition approval. You can download this tool from CodePlex: https://copysecuritypermissionsax.codeplex.com/ Please feel free to make suggestions and improvements.