Change Form Contrl through class in Ax 2012

Description:-

In my one of project I need to changes form controls through class. Here is the solution to change the form controls through class in Ax 2012.

First of all table the table, form and classes name like below I have given for demonstration.
  • Form Name: - Form1
  • Table Name: - Table1, Table2
  • Class Name: - Class1
In Table1 I have some fields like ItemId to modify and get the dimension value for that selected ItemId.
So in Form1 Generate the Modified Method for that Field and code call the Class1.
Declare the Class1 and Call the Class1 and Pass the Table1 as parameter. In Class1 I have created GetInventDim Method.
Class1 Class1;
Class1 = new Class1();
Class1.GetInventDim(Table1);

In Class1 Code for Enable\Disable Control Logic.
Declare the following Classes in Class Declaration.
FormComboBoxControl   formComboBoxControl;
Common                             externalRecord;
FormDataSource               frmDs;
FormRun                            formRun;
FormControl                      frmCtrl;

After in GetInventDim Method.

if(_trans.isFormDataSource())
{
  frmDs = _trans.dataSource();
  formRun = frmDs.formRun();
  if(formRun)
  {
     formComboBoxControl = formRun.design().controlName (formControlStr (Table1, Form1_ControlId));
     if(formComboBoxControl)
     {
       formComboBoxControl.text(" ");
       formComboBoxControl.allowEdit(false);
     }
  }
}

Related Posts

Previous
Next Post »

Thanks for comments.....