Tags

, , ,

Hi All,

Today one of my friend asked me how to do the button enable disable on the form based on the condition of the records . I simply said that either you write it active method or there must be some class written where you have to do the change. Later I found out that it is a listpageform (SalesTableListPage). Most of the new comers dont know how to accomplish such task.

Let me give you small demo how to do it.

I will use the same form (SalesTableListPage) on action pane “Sales Order”, after attachent button, I have to add a button named “Run”.

If the order type is returned then this button should get enabled.

Now if we look at the properties of the form, we can see that class used here is “SalesTableListPageInteraction”. There might be different ways to accomplish this task. I will explain one of them.

Step 1) First I created a button named “RunFormButton” on the form and set the autodeclaration property to yes.

Step 2) There is a method named “selectionChanged()”, here there is a line 

                salesTable = this.currentSalesTable();

                after this line we have the buffer of salesTable, hence we are going to write our code after this.

Step 3) Create new method named setButtonRun(boolean  _run)

             protected void setButtonRun(boolean  _run)

             {

                        this.listPage().actionPaneControlEnabled(formControlStr(SalesTableListPage, RunFormButton), _run);

              }

Step 4) In selectionChanged method find the below code

                   salesTable = this.currentSalesTable();

                after this line we have the buffer of salesTable, add following code into it.

                 if (salesTable.SalesType == SalesType::ReturnItem)

                 {

                            this.setButtonRun(true);

                  }

                   else

                   {

                            this.setButtonRun(false);

                    }

 

Step 5) Run the form and enjoy 🙂

Advertisements