Posts

Showing posts from 2016

Dynamics AX 2009 : Cannot create a record in Sales order header - Updating table (SalesParmSubTable)

During Sales order posting I encountered an issue which was being generated due to below error message: "Cannot create a record in Sales order header - Updating table (SalesParmSubTable). Sales order:*, *. The record already exists." After some analysis and searching this issue I found that this issue sometimes occurs due to database logging enabled on some tables related to Sales Order i.e. SalesParmSubTable, SalesParmSubLine, SalesParmTable,SalesParmUpdate .... Removing these tables from that specific Company Database log setup resolved the issue. Note: For similar issue related to PO I also found a Microsoft fix which may also be helpful in similar scenarios: https://support.microsoft.com/en-us/kb/961909

Dynamics AX X++ job to fetch On Hand Item data on bases of Inventory dimensions

Static void onHandJob(Args _args) { InventOnhand    inventOnhand;     InventDim       InventDimLocal;     InventSum       InventSumLocal;     ItemID          itemId,ItemIdLocal;     InventDimParm   inventDimParmLocal;     InventBatch     inventBatchLocal; itemid = wmsPickingList_OrderPickTmp.ItemId;     while select InventSumLocal             group by InventSumLocal.ItemId, InventDimLocal.inventBatchId,                      InventDimLocal.wmsLocationId, InventDimLocal.LicensePlateId         where InventSumLocal.Closed == NoYes::No               && InventSumLocal.ClosedQty == NoYes::No               && InventSumLocal.ItemId == itemid         join InventDimLocal             where InventDimLocal.inventDimId == InventSumLocal.InventDimId                   && InventDimLocal.inventBatchId != ""                   && InventDimLocal.wmsLocationId !=""         {             inventBatchLocal = InventBatch::find(inventDimLoca

Publishing AX Reports – User or group name not recognized

Publishing AX Reports – User or group name not recognized You may encounter an issue with trying to release reports to your AX environment when you move databases between environments. The error you might receive, during the report release, is  Publish_AXReport: The user or group name ‘xxx’ is not  recognized Even though everything is setup correctly in your AX environment, the error is caused by having additional records in the table SysServerSessions. If from SQL you review the data in this table you should notice that you have records that point to old servers/instances. You need to delete all the records that are not relevant to your current environment. Once done you should be able to deploy reports with getting the user or group name error.

SQL Script to retrive DataBase settings before DB restore

select 'Update SysBCProxyUserAccount set SID = ''' + SID + ''' , NETWORKDOMAIN =''' + NETWORKDOMAIN + ''' , NETWORKALIAS = ''' + NETWORKALIAS + ''''  from SysBCProxyUserAccount  select 'Update SysWorkflowParameters set EXECUTIONUSERID = ''' + EXECUTIONUSERID + '''' from SysWorkflowParameters  select 'Update SysServerConfig set SERVERID = ''' + SERVERID + '''' from SysServerConfig  select 'Update BatchServerConfig set SERVERID = ''' + SERVERID + ''''  from BatchServerConfig   select 'Update BatchServerGroup set SERVERID = ''' + SERVERID + '''' from  BatchServerGroup  select Top 1 'Update Batch set SERVERID =''' + SERVERID + '''' from Batch   select 'Update SYSEMAILPARAMETERS set SMTPRelayServerName = ''' +  SMTPRelayServe

AX Cleanup cache .auc file

To delete AUC(Application Unicode Cache) files we need to perform below steps: 1. Stop AOS 2. Delete AUC files from path :    C:\Users\<UserId>\AppData\Local 3. Restart AOS.

X++ job to treverse AOT objects

static void CusLayerTableFieldAnalysis_Cus(Args _args) {     #aot     #properties     Str                         projectName = "DataDictionary_CUS";     ProjectNode                 projectNode;     ProjectGroupNode            ddProjectGroupNode;     ProjectGroupNode            edtProjectGroupNode;     ProjectGroupNode            tblProjectGroupNode;     ProjectListNode             projectListNode;     TreeNode                    memberTreeNode;                 TreeNode                    projectTreeNode;     TreeNodeIterator            projectIterator;       SysDictTable    dictTable ;//= new SysDictTable(tableNum(CustTable));     SysDictField    dictField;     TreeNode        treeNode;     FieldId         fieldId ;//= dictTable.fieldNext(0);     //ProjectNode projectTreeNode = SysTreeNode::getPrivateProject().AOTfindChild('DataDictionary_CUS');       // find all Private projects     projectListNode = SysTreeNode::getPrivateProject();     // fin

X++ job to treverse AOT Tables

static void TreversrAOTTables(Args _args) {     #AOT     Treenode TableNode;     Treenode Table;     str TableName;     str tableConfigKey;     int i;     int nodeCount;     ;     TableNode = treenode::findNode(#TablesPath);     // Count of all the forms.     nodeCount = TableNode.AOTchildNodeCount();     Table = TableNode.AOTfirstChild();     for (i=1; i<=nodeCount; ++i)     {         TableName = Table.AOTgetProperty("Name");         tableConfigKey = Table.AOTgetProperty("ConfigurationKey");         if (tableConfigKey == 'WMSAdvanced')         {             info(TableName);         }         table = table.AOTnextSibling();     } }

Sample code

ReleaseUpdateDB::indexAllowNoDup( new DictIndex( tableNum (TableName), indexNum (TableName, DateEffectiveIndex)));

Dynamics AX Data Upgrade : No upgrade script was registered for the table * field * (relation *). Register an appropriate upgrade script or add the relation to the exclusion list.

Image
During a data upgrade from AX2009 to AX 2012 R3 we face an issue during UnitOfMeasure Upgrade script in AX 2012 Upgrade check list . The error message was as below: No upgrade script was registered for the table <TableName> field <FieldName>(relation <RelationName>). Register an appropriate upgrade script or add the relation to the exclusion list. The info Log generated is as below: After investigating this issue I came to know that the issue was due to Some Custom Tables Which Were having relation with UnitOfMeasure Table and their relation were not added to the exclusion list, and when the script run it add the Relations to the exclusion list for other Standard tables which can be seen in Class "UnitOfMeasureUpgradeValidator" method "registerExcludedrelations". Adding the custom Code to this method resolved the issue :-)

Table Field Mapping

[ UpgradeScriptDescriptionAttribute( "@SYS136813" ), UpgradeScriptStageAttribute(ReleaseUpdateScriptStage::PreSync), UpgradeScriptTypeAttribute(ReleaseUpdateScriptType::SharedScript), UpgradeScriptTableAttribute( 'CompanyInfo' , false , false , false , false ) ] void updateMappingCompanyInfo() { ReleaseUpdateBulkCopyMap::addFieldNameMapping(#companyInfoTableName#dataAreaIdFieldName,#companyInfoTableName,#dataAreaFieldName, NoYes::No); ReleaseUpdateDB::addBulkCopyFieldOption(#companyInfoTableName,#modifiedDateTimeFieldName, ReleaseUpdateBulkCopyFieldOption::DoNotCopy); ReleaseUpdateDB::addBulkCopyFieldOption(#companyInfoTableName, #modifiedByFieldName, ReleaseUpdateBulkCopyFieldOption::DoNotCopy); }

How to open Microsoft Dynamics AX Development Work Space and generate CIL through Command prompt

How to open development work space through cmd : In order to open development workspace through CMD execute the below command in CMD : cd C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe -development How to generate CIL through CMD: cd C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe -startupcmd=CompileIL

Enterprise portal installation error : The Application Pool or Managed Metadata Web Service may not have been started

Image
Some times during the Enterprise portal installation the setup fails due to following issue :   ERROR    The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator Resolution 1 Make sure the managed metadata service is already started or not. Go to SharePoint Central Administration site -> Application Management ->  Manage Services on server -> Managed meta data ->Start. NOTE: After start the Service once reset the iis by running Command prompt as admin and execute command "IISRESET". Resolution 2 We have to give the "Permission" Go SharePoint Central Administration site -> Application Management -> Service Application -> Manage Service Application. Highlight the Managed Metadata Service that your web application is associated with. (Do not click on the link, just click somewhere else o

TFS Error: The file file.xpo was not correctly imported to the model store in a previous synchronization. Any updates of the file is blocked from AX. Open Version Control, Synchronization log to re-import the file.

While working on TFS with Dynamics AX 2012, sometimes I get the following error when I try to check-out a certain file. This error occure because either you had synchronized your work space with the files that were not in consistent state or you had checked-in your files which had some errors in .xpo code, like a node was missing etc.  The complete error message is as follows:   The file ****.xpo was not correctly imported to the model store in a previous synchronization. Any updates of the file is blocked from AX. Open Version Control, Synchronization log to re-import the file.  To fix this error, open visual studio, go to Team Explorer (Menus-> View-> Team Explorer), and connect to your project with the TFS. After connecting to the project, just locate the file that you want to check out. Right click the file, and click " Check out for Edit ".   Now go back to AOT, right click on that file, and click " Undo Check-out ". Now you can check this file

Shrink the Dynamics AX Database Log Files

The Database log(.ldf) can be shrunk to recover some of the disk space on the DB server. Just ensure you have appropriate backups of the data file(.mdf) The command can be executed when the database recovery option is set to Simple. The recovery option can be found under Database Properties > Options > Recovery Model Just be careful these settings should not be changed in the production without consulting DBA as it will affect the recovery time in case of a crash. More appropriate to do it on Test or Development machines to catch up on disk space. Use <DatabaseName> GO DBCC SHRINKFILE(<Database_Log>,100) GO The first parameter is the logical name for the DB log, which can be found from the Database Properties > Files > Logical Name Column. The second parameter is for size in MB to be set

SQL Query to Insert records in Table from one SQL Server instance to another

Before proceeding with the insert logic make sure following points: 1. Make sure that the target SQL Server is added in sys.servers through SQL Query :           select * from sys.servers 2. if the target SQL Server is not in sys.servers you can add it by using sp_addlinkedserver stored procedure, Such as sp_addlinkedserver '<SEREVR NAME>' Execute the following SQL Query:  INSERT INTO dbo.[TableName]    SELECT *    FROM [ServerNAme].[DataBaseName].dbo.[TableName] SIMILAR SCENARIO CAN BE USED FOR UPDATE AS BELOW: update dbo.SalesTable  set custAccount = ST2.CustAccount  from dbo.SalesTable ST1  inner join [ServerNAme].[DataBaseName].dbo.SalesTable ST2  on ST1.SalesID= ST2.SalesId

Customers import in AX 2012 from Excel JOB

static void CustomerMapping(Args _args) {     SysExcelApplication application;     SysExcelWorkbooks workbooks;     SysExcelWorkbook workbook;     SysExcelWorksheets worksheets;     SysExcelWorksheet worksheet;     SysExcelCells cells;     COMVariantType type;     int row = 1;       #define.Filename('C:\\FileName.xlsx')     CustTable custTable;     CustInvoiceAddress  invoiceAddress;     DirPartyTable dirPartyTable;     LogisticsElectronicAddress logisticsElectronicAddress;     DirPartyLocation    dirPartyLocation;     DirParty dirParty ;     DirPartyContactInfoView dirPartyContactInfoView;       application = SysExcelApplication::construct();     workbooks = application.workbooks();     try     {         workbooks.open(#Filename);     }     catch (Exception::Error)     {         throw error("File not found");     }     workbook = workbooks.item(1);     worksheets = workbook.worksheets();     worksheet = worksheets.itemFromNum(1);//ite

Dynamics AX : Get the file name from the File Path using X++

AX has a standard method in the Global Class to split the file name from the entire file path.The method is fileNameSplit().The method takes filepath as the parameter.It splits the filepath into three different strings filepath,filename,fileextension respectively.The usage of the function can be seen below. Filename filepath;  Filename filename;  Filename fileType;  str fileNameString; ; [filepath, filename, fileType] = fileNameSplit(fileNamePath);  fileNameString= filename + fileType;  Now the fileNameString will return you the filename with extension.

Dynamics AX : How to Merge Multiple PDF files into a single PDF file

Image
This Bolg will help you to merge Multiple PDF into a single PDF file. Thanks to open source dll “pdfSharp”. It made my life easier to convert the C# code to X++ by using the dll. The dll can be downloaded from the below link or you can google and get the dll from other sources http://pdfsharp.codeplex.com/ The pdfsharp.dll file can also be downloaded from the link below: https://drive.google.com/folderview?id=0BzqL3XWsezaCdUZFX3FHNHA0ZWM&usp=sharing Once the dll has been downloaded, you need to add the dll in Client\Bin folder as shown below. Then go to AOT >> References >> Add the  pdfSharp.dll  by using Add reference option and browse till the  pdfSharp.dll  in the bin folder. Now for this purpose I created a class as below: class MergePdf { } Added a static method in this class as below: static container findMatchingFiles(         str _folderPath     ,   str _filePattern   = '*.*') {     System.IO.DirectoryInfo     direct

Dynamics AX Data Upgrade : Table mapping

During data upgrade the mapping algorithm follows the following precedence for source and target table mapping: 1. Check special mapping – this is custom mapping as defined within pre-synchronize scripts 2. Try to map by name, e.g. SalesLine -> SalesLine (Salesline table exist on both source and target system) 3. Try map by DEL_ prefix, e.g. SalesLine -> DEL_SalesLine (salesline table on traget doesn’t exist but DEL_Salesline table exists) 4. Try to map by ID (Salesline or DEL_salesline table on target doesn’t exist but the ID of the Salesline table on source and target is same) 5. Otherwise, mapping error is reported and must be fixed!

Dynamics AX Data Upgrade : Valid Time State Key Error after Upgrading or Updating

Some times during Upgrades we face a compilation error  “Table does not contain a valid time state key. A unique index needs to be marked as a valid time state key.” Cause The index is disabled using  indexAllowDup  method, then properties  AlternateKey  and  ValidTimeStateKey  are reset to default value  No . ReleaseUpdateDB:: indexAllowDup ( new  DictIndex( tableNum (TableName), indexNum (TableName, DateEffectiveIndex))); The error starts to show up then indexes are not enabled correctly using method indexAllowNoDup : ReleaseUpdateDB:: indexAllowNoDup ( new  DictIndex( tableNum (TableName), indexNum (TableName, DateEffectiveIndex))); AlternateKey  and  ValidTimeStateKey  properties are not set using the code and then you start getting compilation error mentioned above. Solution You should use the method  indexAllowNoDupAndDateEffective  instead: ReleaseUpdateDB:: indexAllowNoDupAndDateEffective ( new  DictIndex( tableNum (TableName), indexNum (

Dynamics AX Data Upgrade Using State Transfer Tool

Image
Using the preprocessing upgrade state transfer tool: The preprocessing upgrade state transfer tool helps you minimize downtime during upgrade. The tool also helps you avoid putting an additional load on your production Microsoft Dynamics AX system while you prepare to upgrade it. This topic describes how to create a test system that is a replica of your production system, perform data preprocessing on the test system, and then transfer the completed preprocessing state back to the production system. How the State Transfer Tool Works: The state transfer tool operates on a Microsoft Dynamics AX source system where some of the tasks of the Preprocessing upgrade checklist have been completed. The tool analyzes the code in the upgrade preprocessing project to identify the upgrade staging and framework tables that are required to capture the state of the Preprocessing upgrade checklist. The tool then uses the Microsoft SQL Server Bulk Copy Program (BCP) utility to copy these tables to