Saturday, May 7, 2011

AX 2009: Enhancing your editor scripts

As an AX developer, I find myself using the built-in editor scripts that come with AX a lot. I noticed that there are several times when I would like to have a template for a display method. I create a lot of custom reports that use display methods and  it would save me time if I could build them from a template. The great thing about AX is that if you want something, you can always build it yourself.

I decided today that I was going to go ahead and jump into the Editors Scripts class and build my own display method template. I was surprised at how easy it was. I decided to look at the class that gets called when using the scripts/templates right click option.

It turns out the class being called is named EditorScripts. I took a look at the class and the method "template_method_parm" was the closest to what I was looking for. All this method does is create a dialog to get the parameters used to create the template and passes them to another method.

The parm method calls a class called xppSource and passes it the parameters that were supplied via the dialog.. In the xppSource class there was a method named parmMethod that accepts the parameters and creates the actual template.

So, all it takes is two simple methods. Once I create the two new methods for my display method template, it should be available on the right-click menu. Below is the code I used to create the template_method_display method in the EditorScripts class:

The above code creates a new dialog that requests that the user select a datatype and variable name for the display method, then passes that information to the xppSource class method "displayMethod" which I created:
This method takes the type name and the variable name from the previous dialog and formats it into a string and adds the word Display before them and the parens after "()". The code then creates a code block "{" and indents the code. Creates the return statement and ends the code block "}". 

In the end you get the following on your righ-click screen (ALT+R):


Then when you select display, you are greeted with the following dialog:
Then you must enter your desired values:
Finally, you select OK and you get your method template:

Once you create this template you can have a new display method in a matter of seconds and you can save yourself valuable keystrokes. Go ahead and have fun with the editorScripts class and increase your productivity!

Thursday, May 5, 2011

Social Coding?


When I first started writing code the general stereotype of a coder was that of a loner geek sitting in front of a computer in his mom's basement. This stereotype has gone on to cause a decline in the number of Computer Science students that this country produces every year.

We may have rightfully earned this reputation (I have at times called myself an indoor enthusiast). There are, of course, still plenty of message boards filled with smug coders who think that they are above helping a "n00b" or who are tired of students looking for homework help. These people were, until recently, the vocal minority. They were the ones screaming the loudest and that was all anyone heard.

Recently, this stereotype has changed. Now people are seeing developers as cool, sheik (thanks for pointing out my error Ellie) chic, and interesting people who have a wide variety of interests and who have social lives. This is evidenced by the influence and reach of programmers through Twitter and by a  number of code hosting/social networking sites that have recently started cropping up. There a plenty of places now for Coders to go and find other people who are interested in the same projects and languages. There are sites for finding open source projects like Ohloh, Project Kenai, Launchpad.Net, Git Hub, Source Forge, and Google Code (I'm sure there's even more than that).

There are sites like DZone and Stack Overflow that help bring the community together and solve problems. These communities help programmers from all over the world share ideas, knowledge, and allow for easier collaboration.

The Social Web has been able to bring together like minded people from all over the world and has helped to make computing better for everyone.It has also, hopefully, put to rest many of the bad stereotypes about computer programmers. This should also help to increase the number of students who choose Computer Science as their major and increase awareness of the need to begin teaching computer science in primary school. If you are a programmer (or a parent) find out why schools should teach computer science and the facts about CS education.