Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Wednesday, 30 July 2014

How to enable disable controls of List Page through Interaction Class

To enable or disable an action pane button

  1. In the AOT, expand Forms and find the form for the list page where the action pane button appears. Use theInteractionClass property of the form to get the name of the interaction class for the list page.
  2. Expand Designs, expand Design, and then expand the Action Pane. Get the name of each action pane button that you want to enable or disable based on the list selection.
  3. Expand Classes, right-click the interaction class for the list page, click Override Method, and then clickselectionChanged. The Editor window opens and displays the selectionChanged method.
  4. Check that Control which you want to Enable or Disable has property AutoDeclaration is set to Yes.
Syntax:-
public void selectionChanged()
{
TableName TableBuffer = this.listPage().activeRecord(queryDataSourceStr(QueryName, DataSourceName));
Super();
if(Condition)   //like - if(TableBuffer.fieldName == Something)
this.listPage().actionPaneControlEnabled(formControlStr(FormName, ControlName),true);

Example:-
public void selectionChanged()
{
    Requisition requisition = this.listPage().activeRecord(queryDataSourceStr(RequisitionQuery, Requisition_1));
    super();
    if(requisition.WorkflowApprovalStatus == WorkflowApprovalStatus::Approved)
        this.listPage().actionPaneControlEnabled(formControlStr(RequisitionListPage,Edit),true);
    else
        this.listPage().actionPaneControlEnabled(formControlStr(RequisitionListPage,Edit),false);
  }