Sometimes you get an XML string and it is unformatted. And doesn't have any tabbing and is hard to read. You can copy and paste this string into a box in the link below and it will do that formatting for you.
Fun tool that I use a lot of: http://www.freeformatter.com/xml-formatter.html
This is the XML string unformatted
<XML><Items><Item><Id>60000</Id><Varient>CEU-000001</Varient></Item>
</Items></XML>'
This is the XML string after the formatting
<?xml version="1.0" encoding="UTF-8"?>
<XML>
<Items>
<Item>
<Id>60000</Id>
<Varient>CEU-000001</Varient>
</Item>
</Items>
</XML>
It is a really slick tool that is free to use. I know its saved me a ton of time.
A blog (primarily about Dynamics AX/D365) covering topics like X++, AX for Retail, D365 Commerce, Trade and Logistics, retail concepts, warehousing, etc. Something for everyone. Grab bag blog for whatever I think would help out people in the Dynamics AX/Commerce/Retail community. The opinions expressed on this site are my own and do not necessarily represent the views of my company
Tuesday, October 2, 2012
Tuesday, September 25, 2012
Simple AX container example
Below is a simple example of creating and inserting values into a container, determining the size of the container, and looping over that container to retrieve the values from it.
Since this is a job and I wanted to test out embedding methods into the job, I included that little complexity in here. All that it does is either fill the container with data or leave it empty based on the 'dataInCont' value which stands for data in container. Note that this variable is a global so when declared in that location and using embedded functions/methods, this location acts as the class declaration.
This is AX development 101 stuff but I was using it in a training sample so I decided I might as well slap the code on my blog as well as the resulting information log.
Enjoy!
Resulting infolog from code above:
Since this is a job and I wanted to test out embedding methods into the job, I included that little complexity in here. All that it does is either fill the container with data or leave it empty based on the 'dataInCont' value which stands for data in container. Note that this variable is a global so when declared in that location and using embedded functions/methods, this location acts as the class declaration.
This is AX development 101 stuff but I was using it in a training sample so I decided I might as well slap the code on my blog as well as the resulting information log.
Enjoy!
static void daxTestJob(Args _args)
{
container cont;
int i;
boolean dataInCont = true; // Do we want to run this job with container data? Note this is a global
// This method will either return an empty container or one with data
container test()
{
container contTest;
if (dataInCont)
{
contTest += 5;
contTest += 6;
contTest += -52;
contTest += 'DAXDUDE';
}
return contTest;
}
;
cont = test();
info (strFmt("Length of the container: %1", conLen(cont)));
for (i=1; i <= conLen(cont); i++)
{
info (strFmt("container value %1 is %2", i, conPeek(cont, i)));
}
}
Resulting infolog from code above:
Friday, September 21, 2012
AX 2012 Issue - New field to table and field group saying 'Unretrievable' and disabled
I encountered an issue when adding a new field to an AX table and putting it in a field group. When a form is opened that has a section for this field group where the new field was added has the field disabled and there is text in the field entry section that reads 'Unretrievable' in AX 2012.
QUICK SOLUTION: Weird table sync issue.
I have never seen this happen before in any other AX 2012 environment and was occurring in a development environment where TFS was enabled. It's a pretty simple scenario so I'm not sure why I was seeing what I was seeing. It doesn't get much easier than this. The table was recompiled and synced, environment open and closed, I actually even tried this in several other environments and was not able to replicate this issue. It was just in the TFS synced environment. I could write data in the table browser back-end but not via the form.
SOLUTION: Looks like this was an issue with the syncing of the EDT/Table. I was able to fix this by creating a new field and trying again. I eventually was able to get one to stick. Not sure what was going on. Looks like an issue with the synchronization.
After I had everything working, I changed the alignment property on the data type, synced the EDT, and this issue came back. I then changed the property back, synced the EDT again and the the issue was fixed. I then switched the alignment back to what I wanted, synced, and the issue was fixed then.
QUICK SOLUTION: Weird table sync issue.
![]() |
| Field added to base AX table and field group disabled and reading 'Unretrievable' |
I have never seen this happen before in any other AX 2012 environment and was occurring in a development environment where TFS was enabled. It's a pretty simple scenario so I'm not sure why I was seeing what I was seeing. It doesn't get much easier than this. The table was recompiled and synced, environment open and closed, I actually even tried this in several other environments and was not able to replicate this issue. It was just in the TFS synced environment. I could write data in the table browser back-end but not via the form.
SOLUTION: Looks like this was an issue with the syncing of the EDT/Table. I was able to fix this by creating a new field and trying again. I eventually was able to get one to stick. Not sure what was going on. Looks like an issue with the synchronization.
After I had everything working, I changed the alignment property on the data type, synced the EDT, and this issue came back. I then changed the property back, synced the EDT again and the the issue was fixed. I then switched the alignment back to what I wanted, synced, and the issue was fixed then.
Thursday, September 20, 2012
Max AX method name and best practices
The maximum length for an AX method in AX is 40 characters.
If the name is too long you'll get the compilation error 'Name is too long. Truncate name to '[>40 character method name here]'.
Remember when you name your AX classes, the names should start with the three letter prefix [e.g. abc], then the module it belongs to [e.g. Sales], then the functionality that it follows where appropriately, ending with a brief description of the purpose. The ultimate goal is to be able to see the class name and know exactly what the class extends and if its custom and what it does.
The methods within this class then should be able to not only follow the base overrides (find, exist, modifiedField, etc), but also provide a directed purpose where appropriate. It is good to keep in mind the best practices behind a method when determining the name of the methods.
A refresher around the functions of AX methods best practices. There are a lot more than the below (like keeping variables as local as possible) but these are general.
MSDN: Best Practices for Methods [AX 2012]
Methods should:
Do not have any unused variables in your methods.
If the name is too long you'll get the compilation error 'Name is too long. Truncate name to '[>40 character method name here]'.
Remember when you name your AX classes, the names should start with the three letter prefix [e.g. abc], then the module it belongs to [e.g. Sales], then the functionality that it follows where appropriately, ending with a brief description of the purpose. The ultimate goal is to be able to see the class name and know exactly what the class extends and if its custom and what it does.
The methods within this class then should be able to not only follow the base overrides (find, exist, modifiedField, etc), but also provide a directed purpose where appropriate. It is good to keep in mind the best practices behind a method when determining the name of the methods.
A refresher around the functions of AX methods best practices. There are a lot more than the below (like keeping variables as local as possible) but these are general.
MSDN: Best Practices for Methods [AX 2012]
Methods should:
-
Be logical.
-
Do a specific task.
-
Have no side effects.
-
Be well structured, especially when it comes to good places for overriding and for overlayering.
Do not have any unused variables in your methods.
Wednesday, September 19, 2012
Select statement where condition formatting and placement in Dynamics AX
In Dynamics AX X++, there are a few ways to format a select statement and place the where clauses when using multiple joins. See the two examples below. Both do exactly the same thing but note the difference in placement of the where conditions. Just making sure people know this. Apparently some people do not so at least now its out on the internet somewhere.
I don't believe there is a best practice around this but it should be consistent in your development either way. I prefer option 1 as it reads better in my opinion. The where conditions can be separated a little more and linked back to their initial data source.
OPTION 1:
public static Name storeOperatingUnitName(RecID _storeRecId)
{
RetailChannelTable retailChannelTable;
DirPartyTable dirPartyTable;
OMOperatingUnit operatingUnit;
;
select firstOnly recId from retailChannelTable
where retailChannelTable.RecId == _storeRecId
join recId from operatingUnit
where operatingUnit.RecId == retailChannelTable.OMOperatingUnitID
&& operatingUnit.OMOperatingUnitType == OMOperatingUnitType::RetailChannel
join name from dirPartyTable
where dirPartyTable.RecId == operatingUnit.RecId;
return dirPartyTable.Name;
}
OPTION 2:
public static Name storeOperatingUnitName(RecID _storeRecId)
{
RetailChannelTable retailChannelTable;
DirPartyTable dirPartyTable;
OMOperatingUnit operatingUnit;
;
select firstOnly RecId from retailChannelTable
join RecId from operatingUnit
join Name from dirPartyTable
where retailChannelTable.RecId == _storeRecId
&& operatingUnit.RecId == retailChannelTable.OMOperatingUnitID
&& operatingUnit.OMOperatingUnitType == OMOperatingUnitType::RetailChannel
&& dirPartyTable.RecId == operatingUnit.RecId;
return dirPartyTable.Name;
}
I don't believe there is a best practice around this but it should be consistent in your development either way. I prefer option 1 as it reads better in my opinion. The where conditions can be separated a little more and linked back to their initial data source.
OPTION 1:
public static Name storeOperatingUnitName(RecID _storeRecId)
{
RetailChannelTable retailChannelTable;
DirPartyTable dirPartyTable;
OMOperatingUnit operatingUnit;
;
select firstOnly recId from retailChannelTable
where retailChannelTable.RecId == _storeRecId
join recId from operatingUnit
where operatingUnit.RecId == retailChannelTable.OMOperatingUnitID
&& operatingUnit.OMOperatingUnitType == OMOperatingUnitType::RetailChannel
join name from dirPartyTable
where dirPartyTable.RecId == operatingUnit.RecId;
return dirPartyTable.Name;
}
OPTION 2:
public static Name storeOperatingUnitName(RecID _storeRecId)
{
RetailChannelTable retailChannelTable;
DirPartyTable dirPartyTable;
OMOperatingUnit operatingUnit;
;
select firstOnly RecId from retailChannelTable
join RecId from operatingUnit
join Name from dirPartyTable
where retailChannelTable.RecId == _storeRecId
&& operatingUnit.RecId == retailChannelTable.OMOperatingUnitID
&& operatingUnit.OMOperatingUnitType == OMOperatingUnitType::RetailChannel
&& dirPartyTable.RecId == operatingUnit.RecId;
return dirPartyTable.Name;
}
Tuesday, September 18, 2012
AX 2012 Delete a record from table browser or grid when delete button is not available
In earlier versions of AX, you had access to the red X on the main AX tool bar to allow you to delete a record from a table via the table browser or a grid where there was no delete option.
In AX 2012, this option is not necessarily available. You need to use an AX shortcut now. I always forget what this is so I'm writing a post. Simple stuff I know but its different so I'll write about it. Highlight the record(s) of interest and hit ALT+F9. This will prompt you if you really want to delete the record(s). Unless you have a sudden change of heart, click yes.
Fin
In AX 2012, this option is not necessarily available. You need to use an AX shortcut now. I always forget what this is so I'm writing a post. Simple stuff I know but its different so I'll write about it. Highlight the record(s) of interest and hit ALT+F9. This will prompt you if you really want to delete the record(s). Unless you have a sudden change of heart, click yes.
Fin
Monday, August 27, 2012
AX 2012 for Retail Error - A connection with the Transaction Service has not been enabled
Process:
In implementations, it is necessary to refresh information from the production system to a lower environment so certain issues can be resolved. With this process, there are settings that need to be changed to make sure that the actual production system is not intermingling with the lower environments. If things are not changed properly errors can occur.
Issue:
After doing the PROD DB restore and reconfiguration, whenever a transaction service call is done, the error "A connection with the Transaction Service has not been enabled" is thrown.
While this could be a few things, here are two things that we need to check in regards to proper reconfiguration when seeing this error:
1) Retail Transaction Service Profile is setup for the new environment's AOS
2) POS Terminal 'Transaction Service Profile' value. This should be the value setup in point 1) above
Once these values changes are made, take down the transaction service followed by the AOS. This may not be a required step but it is always good to do this when transaction service errors pop up and it won't hurt anything. Bring up the AOS and then the transaction service once the AOS is back up.
After adjusting these values, push them down to the POS terminal via the appropriate job (N-1090 in base config). Once pushed down (you can check this in the Store DB), conduct a transaction service call where you were getting this error before. As a note, you may need to log out of the POS. I wouldn't think you'd need to but I saw this as an issue after I did it.
Hope this helps with this error!
Subscribe to:
Posts (Atom)



