Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics
I faced this issue “Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics” when I imported MS contoso data into my new created AX environment. Though this is not specific to MS contoso data import, you can have on original post which solved my problem too. http://www.ksaelen.be/wordpresses/dynamicsaxblog/2013/02/ax2012-r2-db-sync-failed-to-create-a-session/
Number sequence framework step by step
There are many posts over the internet address Number Sequence framework, I found a worth sharing slides which tells you; How to create new number sequence How to use number sequence in form How to use number sequence in X++ Microsoft dynamics ax2012 : Number Sequence Framework, Step by Step from Hamdaoui Mohamed Amine
Delete legal entities in AX 2012
Delete a legal entity seems to be a straight forward option in AX, just click on delete button on legal entity form. This does not work sometimes as per your thoughts and you face errors like below. Cannot delete a record in Ledger (Ledger). The corresponding AOS validation failed. Stack trace: Call to TTSCOMMIT without first calling TTSBEGIN. Stack trace (S)ClassesxRecordDelete (S)Data DictionaryTablesDirPartyTableMethodsDelete – line 14 (S)Data DictionaryTablesDirOrganizationBaseMethodsDelete – line 17 (S)Data DictionaryTablesCompanyInfoMethodsDelete – line 31 (S)ClassesxRecorddbOpInTransaction (C)ClassesFormDataSourcedelete (C)ClassesFormRuntask (C)FormsOMLegalEntityMethodstask (C)ClassesSysSetupFormRuntask OR Cannot delete a record in Batch job (BatchJob). The corresponding AOS validation failed. These errors appear when you have transaction data in the legal entity which you are after for delete or there are batch jobs in running state stopping this delete process. There are certain steps to get rid of these errors and also to have a smooth delete process without any issue. Select the company (legal entity) which you need to delete. Go to AOT (Press Ctrl + D) and find class “SysDatabaseTransDelete” to delete transactions first. Run class “SysDatabaseTransDelete”, it will prompt you Yes/No option to delete transactions. Delete them first it will take a while depend on the transaction data you have in your system in this company. Open legal entity form from Organization Administration | Setup | Organization | legal entities. Select legal entity for which you deleted transaction data in step 1 and click delete button. It will take a while.
AX 2012 – Import Free Text Invoices – Header and lines – from one excel file
I got a requirement to upload free text invoices into AX 2012 from one excel file. All the header and lines information was in one excel sheet so I had to came up with different solution than the import process described on many blogs or can be done through built in AX classes. However, those import process work perfectly if you have data into seperate files or only for one record. Here is the job which I used to import free text invoices into AX 2012. In this job I used a table CustomerInvoices (new created table) which contains the data of all excel file. You can easily find out how to import data from excel then instead of using this table you can directly use the excel rows to get the data and insert into Free Text Invoice tables. static void CreateFTInvoicesFromTable(Args _args) { CustInvoiceTable custInvoiceTable; CustInvoiceLine custInvoiceLine; CustTable custTable; CustomerInvoices customerInvoices; // Customized table Map customerFTI = new Map(Types::String, Types::String); Set failedCustAccount = new Set(Types::String); MapEnumerator mapEnum; SetEnumerator setEnum; LineNum lineNum; ttsBegin; while select customerInvoices order by customerInvoices.AccountNum { if (!customerFTI.exists(customerInvoices.AccountNum) && !failedCustAccount.in(customerInvoices.AccountNum)) { select custTable where custTable.AccountNum == customerInvoices.AccountNum; custInvoiceTable.clear(); if (custTable.RecId != 0) { custInvoiceTable.OrderAccount = custTable.AccountNum; custInvoiceTable.modifiedField(fieldNum(CustInvoiceTable, OrderAccount)); custInvoiceTable.InvoiceId = customerInvoices.InvoiceId; custInvoiceTable.insert(); lineNum = 0; customerFTI.insert(customerInvoices.AccountNum, custInvoiceTable.InvoiceId); } else { if (!failedCustAccount.in(customerInvoices.AccountNum)) { failedCustAccount.add(customerInvoices.AccountNum); } } } if (custInvoiceTable.RecId != 0) { custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable); custInvoiceLine.LedgerDimension = customerInvoices.LedgerDimension; custInvoiceLine.Description = customerInvoices.Description; custInvoiceLine.TaxGroup = customerInvoices.TaxGroup; custInvoiceLine.TaxItemGroup = customerInvoices.TaxItemGroup; custInvoiceLine.Quantity = customerInvoices.Quantity; custInvoiceLine.UnitPrice = customerInvoices.UnitPrice; custInvoiceLine.AmountCur = customerInvoices.Quantity * customerInvoices.UnitPrice; custInvoiceLine.ParentRecId = custInvoiceTable.RecId; lineNum += 1; custInvoiceLine.LineNum = lineNum; custInvoiceLine.insert(); } } ttsCommit; mapEnum = customerFTI.getEnumerator(); info(strFmt(‘Following Free Text Invoices are successfully created.’)); while (mapEnum.moveNext()) { info(strFmt(‘Customer Account : %1 , Invoice Id : %2’, mapEnum.currentKey(), mapEnum.currentValue())); } if (!failedCustAccount.empty()) { info(strFmt(‘Following Customer Accounts are not valid.’)); setEnum = failedCustAccount.getEnumerator(); while (setEnum.moveNext()) { info(strFmt(‘Customer Account: %1’, setEnum.current())); } } }
Stopped (error): X++ Exception: Could not find user at SysWorkflowDueDateProvider
I developed a custom workflow and its setup its corresponding configuration, I was able to submit and everything but ended up getting the following error in my workflow history when the workflow system tried to assign it to user which is the part of managerial hierarchy. “Stopped (error): X++ Exception: Could not find user at SysWorkflowDueDateProvider-resolve SysWorkflowDueDateProvider-resolveDueDate SysWorkflowQueue-resume” I setup the workflow assignment for managerial hierarchy (position hierarchy) which was correctly setup under Human Resource > Common > Positions > Position hierarchy. Later when I checked the worker association with users I found that under user relation screen the user IDs are wrongly associated with workers. Unfortunately this error message was coming due to wrong or missing worker and user assoication which is a must step for workflow to be processed perfectly. Workflow always work on Employee (worker) level not on user level so user MUST be associated with the user. I hope this will help someone who runs into the same issue in the future.
SSRS permissions issue; cann’t able to run from AX non admin user
Question: I have been facing the following issue while running SSRS reports from AX non-admin user. Please be informed that all the required permissions have been assigned from reporting service manager like content manager and browser…even I gave all. ANSWER: There are three areas where I have to define the security. 1- Site Settings 2- Folder Settings 3- Individual Folder Security I was missing the last one.
Microsoft Dynamics AX 2012 R3 Virtual Machine is available
Microsoft has released the Microsoft Dynamics AX 2012 R3 demo machine. Download is available at partnersource and customersource. Early in Macy 2014 Microsoft release Microsoft Dynamics AX 2012 R3 and can also be downloaded from the links mentioned in my previous post . At that time the application was general available and could be installed using the Microsoft Dynamics AX 2012 R3 setup files or you could deploy a virtual machine on Azure. This demo virtual machine can now be run at your own hardware using hyper-V as earlier demo machines versions use to run. However, this AX 2012 R3 demo machine is upgraded with latest Microsoft stack: Windows Server 2012 R2 SQL Server 2014 SharePoint 2013 with SP1 Office 2013 with SP1 You can download the machine from either Customersource or Partnersource. Customersource:https://mbs.microsoft.com/customersource/northamerica/AX/downloads/service-packs/AX2012DemoToolsMaterials Partnersource: https://mbs.microsoft.com/partnersource/northamerica/sales-marketing/demo-tools/virtual-machines/AX2012DemoToolsMaterials
Import HRM Positions from Excel through X++
You can use different options to import data into Dynamics AX 2012 specially the subject line entity (Positions). Data import/export framework would be the best option to import it, you can also use excel addins for this purpose. However, due to large number of tables involved in few import process it might be difficult to judge right tables and their sequence. You can also use X++ code to import data into AX either from CSV file or from Excel file. The following job in X++ may help you in importing positions from excel file. static void ImportHRPosition(Args _args) { SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; COMVariantType type; OMOperatingUnit OMOperatingUnit; int row=1; Name name; FileName filename; HcmPosition HcmPosition; HcmPositionDetail HcmPositionDetail; HcmPositionWorkerAssignment HcmPositionWorkerAssignment; HcmPositionDuration HcmPositionDuration; str job; OMOperatingUnitNumber department; ; application = SysExcelApplication::construct(); workbooks = application.workbooks(); filename = “C:\import\HRPosition.xlsx”; ttsBegin; try { workbooks.open(filename); } catch (Exception::Error) { throw error(“File cannot be opened.”); } workbook = workbooks.item(1); worksheets = workbook.worksheets(); worksheet = worksheets.itemFromNum(1); cells = worksheet.cells(); do { row++; HcmPosition.PositionId = cells.item(row, 1).value().bStr(); HcmPosition.insert(); department = cells.item(row, 2).value().bStr(); job = cells.item(row, 3).value().bStr(); select firstOnly OMOperatingUnit where OMOperatingUnit.OMOperatingUnitNumber == department; if(OMOperatingUnit) { HcmPositionDetail.Department = OMOperatingUnit.RecId; HcmPositionDetail.Job = HcmJob::findByJob(job).RecId; HcmPositionDetail.Position = HcmPosition.RecId; HcmPositionDetail.Title = HcmTitle::findByTitle(HcmJobDetail::findByJob(HcmPositionDetail.Job).Description).RecId; HcmPositionDetail.Description = cells.item(row, 4).value().bStr(); HcmPositionDetail.ValidFrom = DateTimeUtil::newDateTime(cells.item(row, 5).value().date(),timeNow()); HcmPositionDetail.ValidTo = DateTimeUtil::maxValue(); HcmPositionDetail.insert(); HcmPositionWorkerAssignment.ValidFrom = DateTimeUtil::newDateTime(cells.item(row, 5).value().date(),timeNow()); HcmPositionWorkerAssignment.ValidTo = DateTimeUtil::maxValue(); HcmPositionWorkerAssignment.Position = HcmPosition.RecId; HcmPositionWorkerAssignment.Worker = HcmWorker::findByPersonnelNumber(cells.item(row, 6).value().bStr()).RecId; HcmPositionWorkerAssignment.insert(); HcmPositionDuration.Position = HcmPosition.RecId; HcmPositionDuration.ValidFrom = HcmPositionWorkerAssignment.ValidFrom; HcmPositionDuration.ValidTo = DateTimeUtil::maxValue(); HcmPositionDuration.insert(); type = cells.item(row+1, 1).value().variantType(); } } while (type != COMVariantType::VT_EMPTY); application.quit(); ttsCommit; }
SysDictTable object not intialized – Data Import/Export Framework
I got the following error while importing Employee Master data using Data Import/Export Framework (from staging to target entities). After doing some debugging I found there was a table “RetailStaffTable” in Emloyee Entity structure but the Retail configuration key was turned off or Retail components were not installed. I ended up deleting the record from the DMFTargetEntityHierarchy table. (Alt+F9 to delete from table browser). I reran the process and it went fine.
Restrict non-admin users to open multiple sessions in AX
Few times client asked to restrict their users to not open AX sessions multiple times. As It may impact on performance somehow. The following code snipet can do this job for you. NOTE: Please take backup of your application before copying code Copy Paste the Following Code in startupPost method of info class in AOTvoid startupPost(){ // To restrict user login form second login xSession session; SysClientSessions SysClientSessions; UserId currentUserId; int counter; currentUserId = curUserId(); if(currentUserId!=”Admin”)// Allow Admin User to login multiple time { while select SysClientSessions where SysClientSessions.userId == currentUserId && SysClientSessions.Status == 1 // 1 : Login 0 : Logout { session = new xSession(SysClientSessions.SessionId, true); if (session && session.userId()) { counter++; } } if (counter >= 2) { Box::stop(“Already Logged-in : The same user id can’t log in twice.”); infolog.shutDown(true); } }}