Tuesday, December 5, 2017

SalesTableInteraction and SalesTableInteractionHelper classes in Ax2012 - to hide actions on the Form


To hide an action buttons on sales older list  and sales order detail based on the condition. we have to customized the below methods on the respective classes.


For: SalesTable Form:

Class :
SalesTableInteraction
SalesTableInteractionHelper

Ex:

Lets say Sales record has a field Exported boolean field and based on this value this Enabled should be Available.

SalesTableInteractionHelper:
Declare a variable on class - UnknownNoYes            isExported;

Add new method to return a boolean value :
public boolean parmIsExport()
{
    #GetCached(isExported, salesTable.Exported == NoYes::Yes)
}

Go to the  SalesTableInteraction  class:

Declare a Boolean variable on the lets say :"maintainGrpButtonEnabled ".

Add the below code on enableHeaderSalesOrder()  method.

maintainGrpButtonEnabled = salesTableInteractionHelper.parmIsExport();
#SetEnabled(formControlStr(SalesTable, EditSalesOrder), maintainGrpButtonEnabled)
#SetEnabled(formControlStr(SalesTable, EditDetailsButton), maintainGrpButtonEnabled)
#SetEnabled(formControlStr(SalesTable, DeleteSalesOrder), maintainGrpButtonEnabled)


For SalesTableListPage:

Add the below code on setButtonSalesOrder () method.

maintainGrpButtonEnabled = salesTableInteractionHelper.parmIsExport();
        this.listPage().actionPaneControlEnabled(formControlStr(SalesTableListPage, EditButton),maintainGrpButtonEnabled);
        this.listPage().actionPaneControlEnabled(formControlStr(SalesTableListPage, EditInGridButton),maintainGrpButtonEnabled);
        this.listPage().actionPaneControlEnabled(formControlStr(SalesTableListPage, Delete),maintainGrpButtonEnabled);


Thanks ,
Mani