Thursday, June 17, 2010

COM error when exporting data...

I've been getting the following error when trying to export some data to Excel using Definition groups:

Method 'item' in COM object of class 'Range' returned error code 0x800A03EC () which means: .

At first I noticed it was only happening when adding the field RecId to the "Field setup" of the export. The problem isn't really the field itself, but actually the way it was being added. When adding a table to a definition group, it automatically pulls in all the fields of that table (except some system fields like TableId, RecId, DataAreaId, etc.). So when you hit the Setup button, it already contains most of the fields.

The table used to store that selection is SysExpImpField. There's a record for each field and it saves the selected field ids in ConvFieldId. It is important to note that it's actually the extended field id that is saved (Field id + array index). From the setup form we have 2 ways of adding more fields, either by using the lookup or by manually typing the name of the field.

If we use the lookup, it calls the Global::pickField function and returns the extended field id selected. However, if we type the name of the field, it will then use the function fieldname2id. fieldname2id returns the FieldId NOT THE EXTFIELDID...

So I added a quick hack to the edit method SysExpImpField.fieldName :


// BP Deviation Documented
edit fieldName fieldName(boolean set, fieldName name)
{
if (set)
{
this.ConvFieldId = fieldname2id(this.ConvTableId, name);
//MVaillancourt. Haka. 20100617
//fieldname2id does not return the extended fieldid. if the id is smaller than 65 536, convert to extended
if (this.convFieldId < 0x10000)
this.convFieldId = fieldid2ext(this.convFieldId, 1);
//MVaillancourt. End
}

return fieldid2name(this.ConvTableId, this.ConvFieldId);
}

Thursday, June 10, 2010

Forms not saving user layout changes

You may have come across some forms where users complained it wasn't saving the layout changes they were making. The problem is quite easy to fix if the link between the 2 forms is straightforward.

I've had to deal with this issue for a client and this is what it looked like:

A custom invoice history screen was created and it lists all the invoice lines for a customer. The invoice history screen is called from the invoice journal header form. A normal button with the call to the form in the click method was used.

void clicked()
{
FormRun fr;
Args args;
;
super();

args = new Args("CusInvoiceHistory");
args.parm(custInvoiceJour.OrderAccount);
fr = new FormRun(args);
fr.init();
fr.run();

fr.wait();
}

Although this will call the form, it will not save any user customization (Window size, column width, column order, etc.). The problem lies in the fact that no Menu Item is used. I quickly changed the Button to a MenuItemButton that points to my form, changed the init of my form to properly initialize my query and that did the trick. There is no reason a call to another form shouldn't be done with the use of a Display Menu Item (I can't think of any at the moment). It is the "standard" way of properly linking the forms together.

Have an exception to that rule? Let me know in the comments.

Friday, June 4, 2010

AX, Android, Emulation.... What now?!

So much to do... so little time!

This little blog of mine never really took off and for the most part, I'm the only one to blame. It's not that I don't want to keep it updated, it just hasn't been anywhere near my top priorities this year (or the last few years for that matter :p). Well, are things about to change? Most likely.

I'm still going to try and keep my posts in line with the work I do... that is Microsoft Dynamics AX development, but since I'm now the owner of an Android smartphone, you might see me post a few Android stuff here and there if I ever get everything setup right. First thing I'll do is probably port my Chip8 emulator to the Android. (No Hellow World nonsense for me) That should get me familiarized with the platform and I'll be able to move on to bigger projects after that.

More to come!