List panel can be very useful functionality especially from user perspective.
The standard Dynamics AX 2012 tutorial form shows how to initialize list panel control but with standard use of tabs “Overview” and “Panel” which is useful in situation like assigning specific roles to user but sometimes we might require list panels to be initialized without tabs. We have scenario when we need mark some of vendors as temporary vendors, they will be only used within specific time. We have separate tables to store temporary vendors and their times of being active.
We want to shows those temporary vendors under Purchase ledger in new list page.
List page is standard VendTableListPage form with range showing only those suppliers with existing record as temporary vendor.
Instead of “New Supplier” we will have “New Temporary vendor” under which we will have new form with use of list panels.
We will start off with creating simple from and adding two new data sources:
Create group to hold the list panel:
Now we will do coding, we need to prepare three new methods that out list panel will use – one for catching suppliers that aren’t temporary, one for catching only temporary vendors and one for validation:
You may notice in both temporaryVendors() and suppliers() methods we passes data about AccountNum twice we did this as we will use this field as our data field in initialization of our list panel in init() of form methods:
If we opened form at this point we will notice that list panels are there but they not filled in up to this point the steps are quite similar to creating list panels from tutorial form the difference is where should we put our fill() method for list panels, in this example we create new method called updateListPanel() and use it in run() method of form:
We have now list panel with suppliers filled in and the temporary vendors empty as we don’t have any records yet but before we start playing we need to add more code so when we create the temporary vendor it will create time related record as well.
In my table VendTableTemp I have method for creating or updating the time related records:
I put this method in insert() and delete() method of the same table as those methods will be called whenever I move supplier to temporary vendors or remove him:
No our form works how we wanted to but the original list page form is not refreshing after adding values so we need to add refreshing code to close():
Final view of the form and tables: