Tutorial: Custom work types and shipment notes on the mobile device in Warehouse management module in Dynamics AX 2012 R3
Read XML file in AX 2009 / 2012
static void ReadXml_New(Args _args)
{
XmlDocument xmlDoc;
#define.node("Data\Invoice")
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord;
XmlNodeList xmlRecordList;
XmlNodeList xmlFieldList;
XMLElement xmlEl;
XMLNode xmlNode;
//CustTable carTable;
//DictTable dTable = new DictTable(tablenum(CarTable));
int i, j, fieldId;
//#CarsXmlTags
;
// Create an XmlDocument object to hold the
// contents of the xml-file
xmlDoc = new XmlDocument();
// Load the content of the xml-file
// into the XmlDocument object
xmlDoc.load(@"c:\Users\abc\Desktop\myxmlInvoice.xml"); // @'C:\Users\abc\Desktop\Invoice.xml'
// permission.assert();
//doc = XMLDocument::newXml(xmlDoc); // this line is to take xml parse data as a parameter and creating new xml file in the code.
// Get the root node
xmlRoot = xmlDoc.getNamedElement("Data");
// Get all child nodes (records)
xmlRecordList = xmlRoot.childNodes();
// Loop through the list of records
for (i=0; i {
//carTable.clear();
// Get the current record from the
// record list
xmlNode = xmlRecordList.nextNode();
xmlRecord = xmlRecordList.item(i);
// Get all child nodes (fields)
xmlFieldList = xmlRecord.childNodes();
// Loop through the list of fields
for (j=0; j {
// Get the current field from the
// field list
xmlField = xmlFieldList.item(j);
// Set the matching field in the carTable
// to be equal to the inner text
// (the text between the tag and end tag).
info(xmlField.name());
//carTable.(dTable.fieldName2Id(xmlField.name())) =
info(xmlField.innerText());
}
// Insert the record into the carTable
//carTable.insert();
}
}
DAX 2012 toolset
Get default financial dimension values through X++ code
This topic is not new and we have lots of blogs available on it. Yasir Co-blogger also explained this quite well in his blog. The purpose to share this again here that I have did some minor modifications in his job to get both attributes (Value and Name) for Default dimension. Complete code is here.
static void GetDefaultDimensionAttributeName(Args _args)
{
DimensionAttributeValueSetStorage dimStorage;
HcmPositionDefaultDimension HcmPositionDefaultDimension;
DimensionAttribute DimensionAttribute;
Counter i;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
Common common;
DictTable dictTable;
str Name;
str value;
// get the dimension value from position
HcmPositionDefaultDimension = HcmPositionDefaultDimension::findByPositionLegalEntity(HcmPosition::findByPosition("000001").RecId,CompanyInfo::find().RecId);
// make the dimension storage object
dimStorage = DimensionAttributeValueSetStorage::find(HcmPositionDefaultDimension.DefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
// get attribute select here.
select firstonly dimAttrValue
where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute;
if (dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common = dictTable.makeRecord();
if (common.TableId)
{
select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
name = common.(dimAttr.NameAttribute);
value = common.(dimAttr.ValueAttribute);
}
}
info(dimAttr.Name +"----" +value + "----"+name);
}
}
we can check the other examples on same topic from Yasir’s Blog – Microsoft Dynamics AX

Tutorial: Short pick goods on the mobile device in Warehouse management module of Microsoft Dynamics AX 2012 R3
How to pass the parameter when opening the MenuItem using X++ code AX 2009 / AX 2012
{
Args args = new Args();
;
args.record(VendTable::find("XYZ"));
new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
}
check the caller from in ax 2012
{
if(_args.dataset() == tableNum(CustTable))
{
}
}
Using the .NET Business Connector to read/write data to Axapta in AX 2009
Opening Balance import through DIEF (Data Import Export Framework
Hi Guys and Happy Independence day to all my country mates and Happy Birth day to PAKISTAN
Okie, This exercise is about importing Opening Balance through DIEF (Data Import Export Framework, I am using Dynamics AX R3 CU8.
1 Create “Processing Group” – “Opening Balance”
2 Click Entities and select Entity as “Opening Balance”
3 Select Source data format as “Excel”
We need to create source data format record as this
4 Click Generate Source file for generating the template, We can select all the needed fields here.
5 Click Modify Source Mapping,
Ops here I got the error
Error Message: Assembly containing type Microsoft.Dynamics.AX.Framework.Tools.DMF.ServiceProxy.DmfEntityProxy is not referenced.
Object ‘CLRObject’ could not be created
There can be multiple reason for this issue but I solved it through these steps.
Solution: Above mention error come because you are trying to set parameter without installing its component (Service, Server and Client). Just install those component from setup file and restart the AOS service. Now this error should not bother you this time. :)
After restarting the AX, I have open the parameter form, specified the correct shared working directory and validate the settings.
OK, NOW BACK TO MAIN TOPIC.
5 Click again on “Modify Source Mapping,”
As we need Journal Number to be Auto generated, I modify it by marking JournalNumber auto generated, and I also added the JournalName field in Query Criteria such that all the lines (with the same JournalName value) will be assigned the same JournalNumber
After this select the excel file with data in the ENTITIES form and click preview to viewing the data.
In the last for moving the data to staging table, click “Get staging data” then for copying the data to target, click on Copy data to target.
and here we have the end result
BIG THANK YOU AND HAPPY DAXING :)

My experience upgrading to Windows 10 in 25 mins
Recently I had posted my experience on Updating Windows 10 on my desktop. Thought to share it over here
https://www.linkedin.com/pulse/my-experience-upgrading-windows-10-25-mins-dilip-nair?trk=pulse_spock-articles
Troubleshooting Dynamics AX 2009 Enterprise Portal Unable to generate a temporary class
Error
Server was unable to process request. ---> Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\vmeyu2da.0.cs' could not be found
error CS2008: No inputs specified
Azure VM Tip Cannot connect to VM after changes in cores and memory
I had to change some VM Settings for an Azure hosted VM and after which I was not able to connect back to VM
This blog tip helped me to solve the issue
http://blogs.endjin.com/2014/03/azure-tip-cannot-connect-to-virtual-machine-after-changing-virtual-machine-size/
Power BI for Desktop & Ax 2012
Power BI for desktop is a very powerful tool and can be used to mash up data from different sources. It is definitely one up to the Excel plugins and so far seems to be more lightweight and processes things faster
I will go through my findings with PowerBI and Ax to come up with some examples
Install PowerBI: Download PowerBI for Desktop and there its a usual click install process. There are other versions available for every other device, which i will look at later. There is a detailed article on installing powerBI at c-sharpcorner.
Open up the the application and we shall create a report that looks like this
So once we open up PowerBI, select “Get Data” and select SQL server database

Enter the Database Server, if possible put the database name as well. Ax Databases being so large seems to slow down power BI.

We will now select the Tables/Views from the list. You can use the search bar and select the checkbox. Select the following Tables/Views:
- CustInvoiceJour
- CustGroup
- LogisticsPostalAddressView
After selecting the checkboxes, click the “EDIT” button in the pop up window. This will load the data preview and open the “Query Editor”
Edit Table Columns
Edit the following tables to trim the data being retrieved:
- LogisticsPostalAddressView
- Select the columns: City,CountryReqionID,RecId. Then right click and select “Remove other columns”
- CustGroup
- Select the columns: CustGroup,Name,DataAreaId. Then right click and select “Remove other columns”
- Add a computed field for identification. Click “Add Column” from the ribbon and then “Add custom column”. Set the new column name to CustGroupId and the formula as =[CUSTGROUP]&[DATAAREAID]
Create CustGroupId field for identification
Click Ok and this field will be added
- CustInvoiceJour
- Select fields: Custgroup, OrderAccount, InvoiceAccount, InvoiceDate, InvoiceAmountMST, SalesBalanceMST, SumTaxMST, InvoicePostalAddress, CreatedBy, DataAreaId, Partition, RecId. Right click and click “Remove Other columns”
- Create a new custom column “CustGroupId” similar to the one done for CustGroup Table
- Create a new custom column “InvoiceYear”. the
Once the above is done, Select “Close and load” button, located in the “home” ribbon bar
Relationships
So now that the tables have been defined, we need to set the relationships between them. Relationships in Power Bi, just like powerview in Excel, can only be linked via one field. Hence, why we added a computed column in the tables CustGroup and CustInvoiceJour
Click on “Manage relationships”
Delete any relationships in there (Currently there is one based off the custgroupId, but we shall delete it to make sure we add it all correctly)
- Relate CustInvoiceJour > CustGroup
- Relate CustInvoiceJour > LogisticsPostalAddressView
You should now have 2 relations setup. Close the Manage relations window and we will create our report
Creating the report
Bar Chart
in the field list at the right side of the screen, select the fields Name from the Custgroup table and then the InvoiceAmountMST field from the CustInvoiceJour Table. This will create a Table. Select the Bar chart option on the right side and it will change the view
Map
Click on a blank area in the report. From the field list select InvoiceAmountMST from the CustInvoiceJour Table and then CountryRegionId from the LogisticsPostalAddress. Then select the Map view
Sales by region over time
This will show how sales figures have been flowing by the countries
Click on a blank area in the report canvas. From the field list select InvoiceAmountMST and InvoiceYear from the CustInvoiceJournal. Make sure the InvoiceYear is on the X-Axis. Then select CountryRegionId from LogisticsPostalAddressView. Change the graph type to Line
Hoping to create more reports and make them available
Filed under: Ax 2012, BI Tagged: ax 2012, AX2012, BI, Business Intelligence, Dynamics Ax, PowerBI

Number Sequence auto-cleanup causing blocking
Recently a customer experienced a daily time timeout in their warehouse operations. It occurred around 10.30 every day and lasted for a few minutes. Meanwhile all warehouse operations were blocked.
It turned out that the culprit was a number sequence configuration. One of the many features in the AX number sequence framework is to automatically clean up unused numbers for continuous number sequences. This feature is great for number sequences that are infrequently used. However, for the high volume number sequences this can cause blocking problems.
When generating a new number the auto-cleanup feature will test to see if it is time for clean-up, and if it is it will commence the clean-up right away – – and the clean-up can take minutes. Meanwhile SQL will hold locks prevent anyone from accessing the same number sequence.
Here is a setup of a number sequence that daily will run the auto clean-up, and potentially lock the system meanwhile.
And here is a job to detect similar issues in your installation:
static void FindNumberSequencesCausingLocksDuringCleanup(Args _args)
{
utcdatetime currentSystemTime = DateTimeUtil::getSystemDateTime();
NumberSequenceTable ns;
while select ns
where ns.Continuous == true &&
ns.CleanAtAccess == true &&
ns.LatestCleanDateTime
{
if (DateTimeUtil::getDifference(currentSystemTime, ns.LatestCleanDateTime)
> ns.CleanInterval*3600)
{
info(strFmt("Every %1 hour %2 will lock during cleanup, last time: %3",
ns.CleanInterval,
ns.NumberSequence,
ns.LatestCleanDateTime));
}
}
}
- Does this number sequence need to be continuous at all? Non-continuous number sequences are must faster, and do not require clean up!
- Is the automatic clean-up required to run automatically? It can also be run manually from the Number sequences form for example outside peak hours.
General Update
Essentially, in my new job I will be able to continue blogging and speaking at conferences. In fact, I will be at the AXUG Summit in October and speaking there. This blog will remain my personal blog and the open source projects will be maintained as well (more on that coming soon). Of course as a personal blog nothing I say or post here is backed up by Microsoft (see disclaimer at the bottom of the pages).
Currently we are hard at work on AX7 and I can't wait to start sharing and blogging about all the goodies for developers. But until then, it will probably be a bit quiet here (except for some planned improvements on the AX2012 build automation). Please connect with me on Twitter and stay in touch.
Woflow AX 2009 and AX 2012
Purchase order workflow -> enable and disable the posting buttons.
\Classes\PurchTableType\mayInvoiceBeUpdated
//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;
if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end
\Classes\PurchTableType\mayPurchaseOrderBeUpdated
//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;
if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end
Fix corrupt AX Install/Uninstall files using Microsoft Fixit
[AX2012] Get list of security roles with name
To get export the security roles along with the AOT name of the security will need you to either write something in X++ or go into SQL
I went the SQL route and this is my code:
select S.AOTNAME, L.Text as AOTNAME, LD.Text as DESCRIPTION from SECURITYROLE S Left outer join ModelElementLabel L on L.Module = SUBSTRING(S.Name, 2, 3) and L.LabelId = SUBSTRING(S.Name, 5, 7) and L.Language = 'en_us' Left outer join ModelElementLabel LD on LD.Module = SUBSTRING(S.DESCRIPTION, 2, 3) and LD.LabelId = SUBSTRING(S.DESCRIPTION, 5, 10) and LD.Language = 'en_us'
This will give a list of the AOT names and the Label name and Description
Filed under: SQL Tagged: AX2012, Dynamics Ax, SQL

Anti-Virus Exclusions for SQL Server, SSRS and Dynamics AX AOS Servers for improved performance
The following paths needs to be excluded:
Full Text Index Catalog C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\FTData
Log Files (.ldf) E:\Logs (Path where SQL Log files are located)
TempDB files F:\Tempdb (Path where tempdb files are located)
B. SSRS Server :
ReportingServicesService.exe D:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin
C. Dynamics AX 2012 AOS Server :
Xppil folder C:\Program Files\Microsoft Dynamics AX\60\Server\AXPROD\bin\XppIL
Label files C:\Program Files\Microsoft Dynamics AX\60\Server\AXPROD\bin\Application\Appl
[AX2012] Fetching a Label value from SQL
Coming from my previous blog post Get list of security roles with name , I extracted the label via SQL. I had to break up the Label ID into the Module and then the number.
This allowed me to then query the table ModelElementLabel to get the label value
Following code can get the Label via SQL
NOTE: you need to query the Model database for this
DECLARE @LabelStr as nvarchar(50) Set @LabelStr = N'@SYS12345' select * from ModelElementLabel L where L.Module = SUBSTRING(@LabelStr, 2, 3) and L.LabelId = SUBSTRING(@LabelStr, 5, 7) --and L.Language = 'en_us' -- Uncomment this line to filter by language
This way you wont need to search a label value from within Ax
Filed under: Uncategorized
