Code highlighting

Wednesday, August 22, 2007

tutorial_Form_Dynalink (a small tutorial on dynalinks)

Today I was asked the following question:

"In dynamics we have a Form Named "Form1" I created a button on it "Button1".
It will manage all the records related to the key in main form. There is dyna link created between the datasources. Only records of the currently selected main Key field will be shown. I need the selected KeyField value on the other form. How can I get it?"


So I wrote a small project to show the different possibilities.
In the project you will find 2 forms, 2 tables and a menuItem connecting the two forms.
3 ways of getting the current dynalink value are shown.

Here is a link to the xpo with the project:
download

Here is a screenshot of the result:



Forgot to give some explanations as well: :)
Basically, all the 3 form methods showing different ways of getting the dynalink value are called from the linkActive method in the second (slave) form.
This method is activated by the system every time a record in the parent form is changed, which allows for dynalinks to work. Great method :)

Monday, July 16, 2007

Fetching Data experiment (CacheLookup property)

Playing around with certain table properties at work, trying to improve performance, I decided to post some results today.

The original job was taken from the Dynamics AX Development training materials (III and IV), which, taking the opportunity, I would like to recommend for reading. Especially I enjoyed chapters dealing with performance issues (a topic that is very interesting to me :))

Well, they write about measuring caching there, which they, actually, shouldn't do, because the job they provided won't work in DAX 4.0 (the counters will be zero) (I guess it was simply copy-pasted from DAX 3.0 training materials - you should never use copy-paste, especially with code :) - trust me, been there many times)

Anyhow, I modified the job a little bit to make my research a little easier.
Here are the results I have received for SalesTable:


Basically, running the job may help you decide, what is the best CacheLookup property value for a given table. 
But first priority is reading about it in tutorials or the Inside Dynamics AX book (basically, it's almost the same information on this topic)

You can do some R&D yourself by downloading the job: download
Have fun!

Also visit the homepage

Wednesday, June 27, 2007

A bug in validation of methods' access modifiers and class abstract modifier

While testing the new feature of Tabax plugins today, discovered a bug in access modifiers validation.

It is performed only at compile time.
Which means, that if the compiler doesn't know what object the method belogns to, than the validation is skipped.
And you can run protected and private methods from whereever your code is executed.

Here is a simple example: (press cancel in the dialogs, otherwise you will get a RunTime error, because the method pack is not implemented in RunBase)

static void tutorial_AccessModifiersError(Args _args)
{
    Object runBaseObj;
    SysDictClass dictClass;
    ;
    runBaseObj = RunBase::makeObject(classNum(RunBase));
    runBaseObj.setInPrompt(true);
    runBaseObj.promptPrim();
    runBaseObj.setInPrompt(false);

    dictClass = new SysDictClass(classNum(RunBase));
    dictClass.callObject(methodStr(RunBase, promptPrim), dictClass.makeObject());
}

setInPrompt and promptPrim are both private methods. so they should not be allowed to be called this way.

The same thing can be achived by using DictClass.

The funny thing is:
while writing a test example for this post, I stumbled upon another bug - now it's about the abstract modifier of a class.

You all are probably aware that RunBase is an abstract class and cannot be initialized.
Well, in the example I showed this is done using 2 methods again :)

I guess someone should register these with Microsoft.

Tabax plugins' update - RecentWindows, RecentProjects

After developing 3 great tabax plugins I was feeling a little unsatisfied, because I wanted to add images to the popup menues.

AndyD has developed a class that allows me to do this now.

The project containing the class with the images is "shipped" separately. Depending on where you want to see images in your popups menues or not, you will be able to import it separately if you do.

Download:
You can use the following links to download the projects (version 0.1.1) and the MenuImages class.

RecentProjects v. 0.1.1 -download
RecentWindows v. 0.1.1 - download
Class MenuImages - download

Alternatively you can download them from their homepages on Axaptapedia.

RecentProject - homepage
RecentWindows - homepage

Screenshot: (RecentWindows)

Tuesday, June 26, 2007

AxPaint - make your DAX look cool :)

A couple of months ago I asked Alex Kotov from AxForum to modify a project he wrote for fun half a year ago or so. Today he sent me an e-mail with the project.

A short description of what the tool can do for you: :)
Basically, it just changes the backcolor of your DAX 3.0 (it does not work for DAX 4.0) installation.
You can choose a simple custom color you would like to use, or select an image from your hard drive to use as the background image.
you can select a couple of settings as well (ALL the settings are accessed by pressing Alt + S in DAX after launching the AxPaint form) - like stretching the image or using a 'transparent' background, showing your desktop (you have to set the image path to a specific location for that).

Nothing much, you'd say. But it sure is fun to work in DAX when a nice picture is seen in the background. :)

Installation instructions:
  1. Unzip the archived files.
  2. Place the .bat and .ocx files somewhere where you won't delete them accidently.
  3. Run the .bat file, which will register the .ocx
  4. Import the project into Dynamics AX - the project contains one form AxPaint.
  5. Run the form. It will automatically hide from view. Press Alt + S to run setup.
Custom settings (my preference):
  1. The image path is setup to C:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp - this is the path to the current wallpaper in Win XP (without active desktop)
  2. Show desktop (like Delphi) option is set in the setup dialog.
  3. In the startupPost method of the Info class the following lines are added:  
  4. An external application is used to change the wallpaper on system startup. So every day I have a different look in my DAX :)
Project archive download link:
download

Custom code for the info.startupPost method:


 if (curUserId() == 'ikash')
    TreeNode::findNode("Forms\\AxPaint").AOTrun();


Link to the external WallChanger application:

download

Screenshots: