Saturday, November 27, 2010

To get table value without buffer

Some times in a code we are declaring variables even for non repeated code values. It is possible to get data from the database without declaring any table variables. Some of you might already be awared of this technique. It seems like this:

static void tableValueWithoutDecla(Args _args)
{
// No variables!
;

print (select ProjTable).projID;
pause;
}

Note the parentheses around the select statement. This tells the compiler to create a temporary, anonymous buffer to hold the record. The select statement uses the exact table name and is immediately followed by a field name to get a value from a field.

If you use this there’s no Intellisense to help you look up the field name because the editor doesn’t know the type of the anonymous buffer.

This technique is often used in exist() methods on tables.

Generating and Sending Emails in Dynamics AX

To generate and send emails in dynamics AX we have SysMailer class. I've came accross a very good example and explanation from Brandon George blog. To give an example of how we used this, he added a new enum value to the Sales Status of a sales order called 'Credit Hold'. When a customer is past due, or is over there given credit limit, then the sales order is placed on 'Credit Hold' and a email is sent out to a given list of people (alias group of emails contained on the email server). The people that get this list decided when the sales order can be actually turned from Credit Hold, to Open Order. The automatically generated email is what keeps the flow of this information system controlled, and not being dependant on a user to have to send a email out.

Let's just dive right in and look at the SysMailer example code:


SysMailer mail;
;

mail = new SysMailer();
mail.SMTPRelayServers().add("mail.yoursmtpserver.com");
mail.fromAddress("test@test.com");
mail.tos().add("you@you.com");

// Build the Message
mail.htmlBody(strfmt(""));
mail.subject(strfmt(""));
mail.sendMail();


That's it! Pretty straight forward, and great piece of code that can be very useful when alerting, and sharing of information and events as they occur.

Friday, November 26, 2010

How to export data of some selected tables?

Sometimes when you want to share data in your tables with others, you export it from Administration -> Periodic -> Data export/import -> Export to. But this exports data in all your tables. What if you want to export data from selected tables only? Here is how you can do that.

First create a definition group from Administration -> Periodic -> Data export/import -> Definitions group

In the definition group form, create a new group. Name it XYZ.
Click on Table setup button.
By default, the table setup form has all the tables listed, select and delete all of them.
Now add only the tables you want data to be exported for.
Now click on Administration -> Periodic -> Data export/import -> Export to
In the definition group, specify the group we created above and click OK

In this way, you can export data for selected tables only.

Wednesday, November 24, 2010

EP development Webinar

While exploring the features and customizations on Enterprise portal of dynamics AX. I've came accross a very useful webinar from Channel 9. Diwakar explains the architecture and development in EP with six live demos. I really recommend this video for novoice to expert EP developers.
http://channel9.msdn.com/Blogs/diwakarb/Dynamics-AX-Enterprise-Portal-Development-Webinar

Tuesday, November 23, 2010

Trade and Logistics training

Hi. There is a blog that I would recommend a free blog that gives a very good insight to the main supplychain processes in standard Dynamics AX.
Take a look at the blog http://www.dynamicsaxtraining.com/ that Volodymyr Myronenko is maintaining.
I recommend all new Dynamics AX consultants and developers to look into this blog. It sure give a overall starting point.

Happy blogging.

Wednesday, November 10, 2010

How to Install Dynamics AX 2009 on Windows 7

Recently, when I upgraded my laptop to Windows 7, I decided to install Dynamics AX 2009 on it. Since my computer is not a domain computer so I was unable to even initiate the installer. The reason behind this blockage is that when it compares the name of computer with the local computer it found the same and installation stops.
I made following changes to the registry and then I was able to initiate Installer.

Open registry and go to the path
HKEY_LOCAL_MACHINE | System | Current control set | Computer Name | Active computer Name and change the computer name to some other name.

I modified my Active computer name to some other name and then run the installer. This time it couldn't match the computer active name. However, it gave me warning that the version you are going to use is not compatible and you should install some windows server *.I just ignored the errors. This is not enough. you may have to make some more changes and manual installation of server on your machine. Though it is a bit complicated process for windows 7. However, it is possible!!.

When I was having errors on AOS installation, I followed the guidelines as per this video, it helped me alot
http://www.trainer-it.ru/video/video-ms-ax/video

Though the environment is Russian. However, demonstration is in english. It will be very helpfull for you guys to see and made the changes as described in this video

Once the installation finished undo the registry changes that you've done before.

By this way, you can install Dynamics AX 2009 on windows 7.

Tuesday, November 2, 2010

Enum values in Query ranges

I've come accross a very geniun mistake which most of the developers usually do. Specially those who are working on a single language and donot test their code properly for other languages. This is related to the use of Enum values in Query ranges.

public void init()
{
QueryBuildRange criteriaOpen;
;
super();
criteriaOpen = this.query().dataSourceTable(tableNum(ProdTable)).addRange(fieldnum(ProdTable, ProdStatus));
criteriaOpen.value("Started");
// it does not work in non-English interface!!!

Though you will not find any compilation or run time error with this. However, the query will not read value when you run it in non english environment.

The correct way to use enum in query is

criteriaOpen.value(QueryValue(ProdStatus::StartedUp);
}