Maximize a form in Ax

September 15, 2017 No comment

Change the properties width = ‘column width’ and height = ‘column height’ on the form.

Add the following code in the run-method of the form:

#WinApi ; 
super(); 
WinApi::showWindow(this.hWnd(), #SW_SHOWMAXIMIZED);

Ax2009 Event Processing Error

February 22, 2012 2 comments

I have a customer that gets a error every time the EventJobCUD-batch (Change Based Events) runs. They got the following error:

After some reseach I found out that when 2 fields are changed at the same time, you go several times through the listChangedFieldsEnumerator (location ClassesEventProcessorCUDprocessUpdate)

1
2
3
4
5
6
7
8
9
while (listChangedFieldsEnumerator.moveNext())
{
    // In this simple case we use the new and the original changed field value as
    // recorded at event detection time:
    [thisFieldId, changedFieldValue, origChangedFieldValue] = listChangedFieldsEnumerator.current();
 
    if (rule.AlertFieldId == thisFieldId)
        break;
}

The code underneed simulates the same situation in a small job:

1
2
3
4
5
6
7
8
9
static void Job5(Args _args)
{
    anytype any;
    ;
    any = ABC::A;
 
    // next line will throw a error
    any = BatchStatus::Canceled;
}

And here we get the basic same error “Error executing code: Wrong argument types in variable assignment.”

I modified the code so the anytype is assigned only when the field is correct:

1
2
3
4
5
6
7
8
9
10
11
12
while (listChangedFieldsEnumerator.moveNext())
{
    // In this simple case we use the new and the original changed field value as
    // recorded at event detection time:
    thisFieldId = conpeek(listChangedFieldsEnumerator.current(), 1);
 
    if (rule.AlertFieldId == thisFieldId)
    {
        [thisFieldId, changedFieldValue, origChangedFieldValue] = listChangedFieldsEnumerator.current();
        break;
    }
}

Ax 2012 Editor improvements

December 2, 2011 No comment

In Microsoft Dynamics AX 2012, a new X++ Editor is introduced which replaces the current legacy editor. The new X++ Editor is based on hosting a Visual Studio 2010 Editor Framework control.

Here are a few Tips & Tricks:

You can find more on chanel 9

Change the language at runtime

November 30, 2011 No comment

Normally when you change your language you go to your user options, change your current language and the restart the client. This week I got the question if it was possible to do so in runtime. You can do so by just calling the infolog.language(str 7 _languageCode). All labels that you load after calling this method will be translated to the new language. (more…)

Amount in words

November 28, 2011 No comment

This week one of my customers asked me to place the amount in words on a invoice. I couldn’t believe that sush function wasn’t availible in standard Ax. After some research I found that the Global-class contains the following methods:

(more…)

Portal development

January 31, 2011 1 comment

While surfing the web, I came across a blog from 2 friends (Youri De Brabandere and Christof Decraene) about Enterprise Portal development. For the moment they have only a few posts, but I’m sure their will be more soon.

Have fun with the http://www.axepclipboard.com.

Ax Security got lost

October 7, 2010 No comment

At one of the customers I’m currently working they took the decision to take a look at the spaghetti of security keys. We made a plan of how the new basic security-structure should look like and implemented it. After releasing this new more logical security structure we started to get the message ‘%2 %1 not initialised.‘.

After some research we discovered this issue occurred only with a few user groups and that the message only exists in the KTD-files, so it is kernel related. We checked the AccessRightsList-table for some inconsistencies but no luck. In the end we found a work-around that helped us solving this issue. When we make a export of the security and afterwards we import the export we just made, the issue disappeared by itself. Because there are a lot of user groups that could be infected with this issue, we automated this fix by running the import – export in a job.

Loop all tables

September 16, 2010 1 comment

There is a simple trick to loop all tables that are available in Ax. Just use the Dictionary-class that contains all information about tables.

Small example to list all tablenames + their corresponding Id.

1
2
3
4
5
6
7
8
9
10
static void JeDoe_listTables(Args _args)
{
    Dictionary  dictionary = new Dictionary();
    int         i;
    ;
    for (i=1 ; i<=dictionary.tableCnt() ; i++)
    {
        info(strfmt('%1;%2', dictionary.tableCnt2Id(i), tableid2name( dictionary.tableCnt2Id(i) )));
    }
}

When you combine this with a DictTable / DictField-object, there are lots of possibilities.

How to make methods on fields disappear (aka a bug)

August 5, 2010 4 comments

Me and some of my colleagues are currently working with a customer on a Ax 2009 SP1 RU4. The other day we came to the conclusion that the modified methods on fields in a form suddenly disappeared. I know, you should write as less as possible code on a form, but sometimes there is no way around this.

After some research we found a reproduction how these methods suddenly disappeared:

  1. Go tot the AOT and chose a form
  2. Open the [FORM] -> Data Sources -> [TABLE] -> Fields -> [A FIELD] -node
  3. Add a method (for example the modified-method)
  4. Save your form
  5. Go to the properties of the table in the datasource
  6. Place your cursor in the table property (properties window)
  7. Push ENTER

The result is that the table will be reloaded in the form and all methods you created on the fields will be gone. So here you have another reason why you shouldn’t write lots of code on your forms. You can only lose it by accident.

Records with RecId 101090

August 4, 2010 2 comments

I was using the postload method of the HRMBenefitType-table to fill the description-field with language-sensitive description (from LanguageTxt). This works fine when I view the record, but not when I use a lookup.

I’ve put a break-point on my postload method and noticed the recId (this.recid of the HRMBenefitType table). This is always the 101090. When I check this in the tablebrowser, this does not match the actual RecId valule.
I checked the SQL-trace-log and noticed the following instruction:

SELECT A.HRMBENEFITTYPEID,A.DESCRIPTION,A.RECVERSION,101090 FROM HRMBENEFITTYPE A WHERE (DATAAREAID=?) ORDER BY A.DATAAREAID,A.HRMBENEFITTYPEID OPTION(FAST 1)

The solution to this problem is simple. Just change the CacheLookup property to EntireTable and the strange behaviour of the RecId-field stops.

Next Page »