Code highlighting

Wednesday, February 21, 2007

Dynamics AX Tutorials

Hello, everyone.

I was going through the Jobs node in my application recently, and stumbeled upon a lot of good examples of different programming technics. I thought it would be nice to share what I have :)

So with this post I will start a series of tutorials on Axapta development.

Today's post is about selecting multiple records on a form (using checkboxes instead of standard Axapta method)

The homepage for this tutorial in on Axaptapedia

It is a simple tutorial form based on InventTable datasource. You can select multiple lines and process the lines by pressing Process lines button.

Here is a short list of what is covered in the tutorial besides the main point of processing selected lines:
  1. Using edit methods in a grid of a form.
  2. Using Foundation class Set to collect selected lines.
  3. Using SetIterator class to go through elements of a Set object.

Preview of the form

Thursday, February 15, 2007

AxCopyTableFieldListToClipboard - another IDE extension tool for Microsoft Dynamics AX 3.0

Hello, readers.

Here is another tool for Dynamics AX developers.
Homepage

All it does is populates the Windows Clipboard with the lines that you can paste into your code, so you won't have to retype the same code many times.

Download the tool here

Features (You can ... ):
  1. Insert a variable declaration before using the name; You will have to move the declaration where it belongs if pasting in the middle of a method.
  2. Insert a call to clear() method of a table variable in order to clear its contents. This is useful, for example, when doing inserts in a loop.
  3. Specify a different variable name than the one by default (tableName). If the variable is unacceptable, the image on the right will point out the mistake.
  4. Choose which fields to copy into the clipboard. There are 2 presets so far. The list will be extended in future releases.
  5. Insert a call to insert() or update() after the lines with field values assignment.

The tool can be integrated into the system in a couple of ways:

  • Insert the menuItem AxCopyTableFieldListToClipboard into the SysContextMenu menu. The text "Copy Table FieldList" will be automatically added to the context menu on AOT objects. In order to sort this out and show the text only for tables, you have to modify the method verifyItem of the SysContextMenu class. Paste the following code into the appropriate section (after case MenuItemType::Action:)
    //--> AxCopyTableFieldListToClipboard_ikash date=2007-02-11 txt='Show in menu only for tables'
case menuItemActionStr(AxCopyTableFieldListToClipboard):
if (this.selectionCount() != 1 firstNode.AOTIsOld())
return 0;

if (!docNode && firstNode.sysNodeType() == 204)
return 1;

return 0;
//<-- AxCopyTableFieldListToClipboard_ikash
  • Insert the menu Item into the GlobalToolsMenu or the DevelopmentTools menu. Then select a table in the AOT and run the menu.
  • You can add the bmp image attached to the project into the plugs folder of Tabax and you will automatically be able to launch the tool from the Tabax toolbar.
  • You can select a table name in the editor and call the tool from the editor scripts. In order to insert the tool into the editor scripts create a method with the following code in the EditorScripts class.

void AOT_Copy_TableFieldList(Editor e)
{
Args args = new Args();
;

args.parmObject(e);

new MenuFunction(menuItemActionStr(AxCopyTableFieldListToClipboard), MenuItemType::Action).run(args);
}


Also (especially DAX 4.0 users), take a look at the link to Casper Kamal's post. He describes similar functionality already included in the 4.0 release.
Hey, great to know MS developers and I are thinking the same thoughts ;)
Anyway, here is the link:
http://casperkamal.spaces.live.com/Blog/cns!9138ED475277CD63!221.entry

Thanks to:

  • aidsua - for a hint on the match function
  • AndyD - ListView setColumnWidth help and WinApi stuff




Thursday, February 08, 2007

EditorScripts.addIns_OpenInAOT() script update

HOMEPAGE

Moreover, I updated the script that finds the selected object in the AOT with the new code fixed by AndyD - now the selected line is parsed correctly even if selected by keyboard.
You can download it from it's homepage only, as this editor is not well suited for copy/pasting of code. :)
AxCreateNewProject version 1.3.1 available

I have also upgraded the tool for creating new projects to version 1.3.1

The new feature are:
Version 1.3.1
Fixed a small bug I stumbled upon recently: If you temporarily turn off the project prefix that contains a long name, and enter a long name for the project, the validation fails telling that the project name is too long - the CheckBox value is not analyzed.

Version 1.3
Now you can update an existing project adding new project nodes to it. Just select the project you want to update and hold the Ctrl key when calling the AxCreateNewProject tool. This will automatically initialize the Settings Tree with the project group nodes found in the selected project. Also, the warning confirmation message won't be shown when you press the OK button and the existence of a project with the same name is not considered an error in the image window.

Moreover, you can now selectively duplicate the objects of an existing project together with the project group nodes. In order to do this select an existing project for update and simply input a new name for the project. You will notice that a button Copy Objects will appear in the bottom left corner of the dialog window. Pressing this button will add the objects found in the selected project into the Settings Tree and will be copied into the new project as well. You will be able to deselect some of the objects (see Known Issues) if you do not need to carry them over to the new project.

You can download the new version HERE or from the Homepage
AxGoToDeclaration


I haven't posted in a while. Work, work...

Well, meanwhile, I made some new handy tool for Axapta developers.

Purpose
Finds the declaration of the selected variable and opens the editor on the line with the declaration

Functional capabilities
Searches the current method first. If the declaration is not found, goes to the root of the object and looks in the classDeclaration method. If still not found, continues on with the parent of the class.

Implementation
In order to use the tool simply import the project
HERE
and post the following code as a new method of the EditorScripts class:

void AOT_goToDeclaration(Editor e)
{
AxGoToDeclaration goToDeclEngine;
;
goToDeclEngine = new AxGoToDeclaration(e);
goToDeclEngine.goToDeclaration();
}




Known Issues:
  • ParserClass does not parse the constructor (new) method. So variable declarations cannot be found from this method.
  • Does not find variables this, element, etc.
  • Does not find objects with AutoDeclaration set to Yes on forms, nor the datasources

What is planned for upgrade:
  1. Open AOT objects when this or element is selected (table, class, form, etc)
  2. Open AOT objects with the property sheet for objects with AutoDeclaration = Yes
  3. Include global classes into the search

Credits

Thanks to

  • AndyD - for the timer AOT edit code and the selectedLine method modifications
  • MaxBelugin - for ParserClass description

Feedback

If you have any comments or suggestions, please feel free to contact me.