Tuesday 5 July 2016

Interaction Class in Ax 2012

Interaction Class

                           Interaction class contain some x++ logic to handle user interactions and make buttons or other controls visible or enabled.

                              To achieve more control over how your model driven list pages behaves, you can specify a custom interaction class by using interactionclass property of the form. The name of your class end with Listpageinteraction. It should inherits from SysListPageInteractionBase.

  •   Interaction class extends SysListPageInteractionBase class.
  •   Here we are having override methods

Initializing           :  Called when the form is initializing – Similar to the form init method
intializeQuery          :  Also called when the form is initializing – Similar to the datasource init method
selectionChanged   :   Called when the active record changes – Similar to the datasource active method.
setButtonEnabled   :  Should be overridden to dynamically enable/disable buttons based on the current selection. This is called from the selectionChanged method.
setButtonVisibility  : Shows or hides grid fields. This method is called once when the forms opens


  • difference between interaction classes and normal classes?

              The interaction classes are extending a base ListPageInteraction class. This has some methods supported by the kernel to interact e.g. with initializations of the list page form. Other classes can be build stand alone to execute e.g. a batch process or represent a web service or posting classes.

SelectionChanged 
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);
}




No comments:

Post a Comment