Adding only one Dimension in Dialog

Warning: This patch did not work for me in Axapta 3.0. It for sure correctly creates the dialog field, but you are unable to actually set the value for it. Having the Dimension[2] field appended as outlined below results in runtime errors when trying to fill in a value into the field (f.x. during the putToDialog called after unpack). I have not had time to investigate this further, however, it seems to me that the array index display would need to be added to the DialogField's runtime state and then taken into account when setting / getting the value.

To add a new field in a dialog we use addField method. When we try to add for example Dimension field Axapta adds all the fields automatically. But sometimes we need to add only one particular field.

Idea
To solve this problem we just need to pass array index as parameter.

Solution
1. Add into Dialog class addField method another one parameter:

DialogField addField(   int         type,    FieldLabel  label   = ,    FieldHelp   help    = ,    ArrayIdx    idx     = 0 //GRR modified for ArrayFields    ) {   DialogField DialogField;

fields += 1; DialogField = new DialogField(this,type,fields); this.addCtrlDialogField(dialogField.name);

//   dialogField.init(this); //standard dialogField.init(this, idx);//GRR modified for ArrayFields

if (label) dialogField.label(label); if (help) dialogField.helpText(help);

this.addDialogClass(dialogField);

return dialogField; }

2. Add into DialogField class init before while (f <= arraysize) loop following lines: //void init(Dialog dialog)//standard void init(Dialog dialog, ArrayIdx idx=0)//Modified for ArrayFields { ....   //Added by GRR for ArrayFields --> if((idx)&&(idx<=arraysize)) {       f = idx; arraysize = idx; }   //Added by GRR for ArrayFields <-- while (f <= arraysize) { .... } Here we add necessary field.

3. Now we may add in dialog only one necessary field: dialog.addField(TypeId(Dimension), , , 1);

4. You can use only standart: static void test_sysDimension(Args _args) {       Dialog      dialog      = new Dialog; DialogField addField   = dialog.addField(typeid(SysDim)); ;   addField.control.arrayIndex(SysDimension::Department+1); addField.label(queryValue(SysDimension::Department)); dialog.run; }