Showing posts with label Form Parts. Show all posts
Showing posts with label Form Parts. Show all posts

Friday, December 30, 2011

WALKTHROUGH - Creating Fact Boxes in AX 2012 - Part IV (Final Post)

Hi,

This is the last post (http://axwonders.blogspot.com/2011/12/walkthrough-creating-fact-boxes-in-ax_29.html) on the series WALKTHROUGH - Creating Fact Boxes in AX 2012. In my last post we took care of primary indexes for the Eduardo_CustCarTable. In addition, we also talked a little bit about Parts and FactBoxes in AX 2012, and that we needed to create a query before displaying data inside a FactBox.
In this post we are going to create 4 forms, 2 info parts, 2 menu items, 2 queries, and finally will create a new form part in the CustTableListPage to see how everything links together.
First we are going to create the Eduardo_VehicleTypeTable, Eduardo_VehicleModelsTable, and Eduardo_VehicleMakeTable, and Eduardo_CustCarTable forms. The four have the same requirements, and the only element that changes is the data source table they use.
In addition,  three these forms (Eduardo_VehicleTypeTable, Eduardo_VehicleModelsTable, and Eduardo_VehicleMakeTable) will have an ActionPane with only two buttons; (1) new and, (2) delete.
The  Eduardo_CustCarTable form, however,  will contain an extra ActionPaneTab to hold the butons to open the orther three forms.

Steps:
1.       In the AOT, right-click the Forms node and select New Form.
2.       Rename the form to Eduardo_VehicleTypeTable.
3.       In a second AOT, locate the table Eduardo_VehicleTypeTable.
4.       Drag the table Eduardo_VehicleTypeTable to the DataSources node on  the Eduardo_VehicleTypeTable form.
5.       Expand the Designs node on the Eduardo_VehicleTypeTable form.
6.       Right-click the Designs node and select New Control > ActionPane.
7.       Expand the ActionPaneTab and then the ButtonGroup.
8.       Right-click the ButtonGroup node and select New Control > CommandButton.
9.       Set the following properties:

a.       ButtonDisplay: Text & Image Left
b.      Text: New
c.       NormalImage: 11045
d.      ImageLocation: EmbeddedResource
e.      Primary: Yes
f.        Command: New


 
10.   Right-click the ButtonGroup node and select New Control > CommandButton.
11.   Set the following properties:

a.       ButtonDisplay: Text & Image Left
b.      Text: Delete
c.       NormalImage: 10121
d.      ImageLocation: EmbeddedResource
e.      SaveRecord: No
f.        Primary: Yes
g.       Command: Delete Record

12.   Right-click the Designs node and select New Control > Group. Change the Name to Body.
13.   Right-click the Group [Body] node and select New Control > Group. Change the Name to GridContainer.
14.   Right-click the Group [Body] node and select New Control > Group. Change the Name to Splitter.


 
NOTE: To make the Splitter work, you will need to overwrite the Form's init method with the following code:


15.   Right-click the Group [GridContainer] node and select New Control > Grid.
16.   Expand the DataSources > Eduardo_VehicleTypeTable > Fields node.
17.   Drag all the fields to the grid control.
18.   Save your changes to the form.
19.   Open the form by pressing Ctrl+O.
20.   If you haven’t already done so, populate the table by entering your own data in to the form.
Repeat steps 1- 20 for the other three forms (Eduardo_VehicleMakeTable and Eduardo_VehicleModelsTable, and Eduardo_CustCarTable ).
The following image depicts the Eduardo_VehicleModelsTable form, so you get an idea how the three forms created above should look like.



Then if you open the Eduardo_VehicleModelsTable you should see the following (if you have some data)



Now, we are going to add anew ActionTab to the existing ActionPane control in the Eduardo_CustCarTable form. This action will create a new tab and three buttons (within the tab) that will open the three forms we created earlier.


Steps
1.       Right-click the ActionPane node and select New Control > ActionPaneTab.
2.       Change the following properties:
a.       Name: Vehicles
b.      Caption: Vehicle Management
3.       Create 4 new Display Menu Items by dragging each form to the Menu Items >Display Node.



4.       Drag the Eduardo_VehicleMakeTable, Eduardo_VehicleTypeTable, Eduardo_VehicleModelsTable Menu Items to the ButtonGroup located in the Form Eduardo_CustCarTable form > Designs>ActionPane>ActionPaneTab:Vehicles> ButtonGroup
The following image shows how a Menu Item is created after I dragged the first form to the MenuItem>Display node.

5.       Set the following properties for each Menu Item Button:
a.       NormalImage: This will allow you to “attach” an image to the button.
b.      Big: Yes (This will make it big)
The form should look like the following image:

Now that all our forms are ready, we are going to start developing to display data in a FactBox in both the Eduardo_CustCarTable and the CustTableListPage forms.
To better understand what we are doing, I would like to review what a List Page is before moving forward with the FactBoxes.

List pages are the primary method of displaying data in Microsoft Dynamics AX. They can show lots of data from many tables, in a number of formats. They have consistent designs and functions. They can easily be displayed in the enterprise portal.



The components of a list page are:

1.   The Grid displays a list of records. It displays only a few of the most important fields for each record.
2.   The Filter bar is used to enter search criteria. This filters the list in the data grid to show only the records which an end-user is interested in.
3.   The Preview Pane displays more fields about the selected record. This helps to ensure you have selected the correct record in your search.
4.   FactBoxes display more information about the selected record from related tables.
5.   The Action Pane contains menu items you can use to do typical tasks related to the highlighted record.
Now, let’s create a FactBox for the Eduardo_CustCarTable. The main idea of this FactBox is to show only the related detail data of Car's model for a selected record.
We need to first create a query. Because we need to for this project, we’ll create the two.
Steps:
1.       In the AOT, right-click the Queries node and select New Query, and rename the new query to Eduardo_VehicleModelsQuery.
2.       In a second AOT, locate the Eduardo_VehicleModelsTable.
3.       Drag the Eduardo_VehicleModelsTable to the DataSources node on the Eduardo_VehicleModelsQuery .
4.       Expand the Eduardo_VehicleModelsTable _1 data source.
5.       In the property sheet for the fields node set the Dynamic property to Yes. This means all fields in the table will be included in the query.




Repeat steps 1 to 5 for the Eduardo_CustCarQuery.
Now it is time to create a Part for each of the queries we just created.
Steps:
1.       Right-click the Info Parts node and select New Info Part.
2.       In the property sheet for the new info part, set the Name property to Eduardo_VehicleModelsInfoPart, set the Caption property to Cars Models, set the Query property to Eduardo_VehicleModelsQuery.
3.       Right-click the Layout node in the info part, and select New Group.
4.       In the property sheet for the group, set the Repeating property to Yes.
5.       Right-click the new group and select New Field.
6.       Set the data source and data field for each of the fields exist in the Eduardo_VehicleModelsTable _1 data source (VehicleModelID, VehicleTypeID, VehicleMakeID, Status, Description)
Repeat steps 1 to 6 for the Eduardo_CustCarsInfoPart. The InfoPart should look like the following image:

NOTE: For the Eduardo_VehicleModelsInfoPart to work correctly in Eduardo_CustCarTable form, we need to tell the Eduardo_VehicleModelsTable that the relationship we have with the index Eduardo_VehicleModelIdx is on the EDT (See next image)
Now the step we all have been waiting for, lets add a new FactBox to the Eduardo_CustCarTable form.
Steps:
1.       Create a new menu item for the info part, by dragging the Eduardo_VehicleModelsInfoPart to the Menu Items > Display node in the AOT.
2.       Locate the Eduardo_CustCarTable form in the AOT.
3.       Drag the Eduardo_VehicleModelsInfoPart menu item to the Parts node in the Eduardo_CustCarTable form.
4.       In the property sheet for the new part reference, set the DataSourceRelation property to Eduardo_CustCarTable.Eduardo_VehicleModels.

5.       Save your changes to the Eduardo_CustCarTable form.

Press CTRL+O to open the Eduardo_CustCarTable, and if everything went OK the form should look like the following image:


Pretty cool, isn't? If you click on a different record, the FactBox information will change to the specified relationship with the VehicleModelID field.
Now, let's do the same with the CustTableListPage.

Steps:

1.    Create a new menu item for the info part, by dragging the Eduardo_CustCarsInfoPart to the Menu Items > Display node in the AOT.
2.    Locate the Eduardo_CustCarTable table in the AOT.
3.    Expand Eduardo_CustCarTable table.
4.    Right-click the Indexes node and select New Index
5.    Rename the index to CustIdx



6.    From the fields node on the table, drag the CustAccount field to the CustIdx index.
7.    Save your changes to the table.
8.    Locate the CustTableListPage form in the AOT.
9.    Drag the Eduardo_CustCarsInfoPart menu item to the Parts node
10. In the property sheet for the new part reference, set the DataSourceRelation property to EDT.VetCustPetTable.CustAccount.

The CustTableListPage should look like this:



This concludes this series of posts about FactBoxes in AX 2012. I hope you have enjoyed this tutorial and that you will share it.

Take Care!

Thursday, December 29, 2011

WALKTHROUGH - Creating Fact Boxes in AX 2012 - PART III

In my last post (http://axwonders.blogspot.com/2011/12/walkthrough-creating-fact-boxes-in-ax_28.html ), we created 3 EDT’s, 4 tables and created the relationships we needed to hold the Auto Rental data.  In this short post we are going to talk about primary indexes, and then we will create one for the Eduardo_CustCarTable.  In addition, we are going to learn a little bit more about Form’s Parts in AX 2012 before jumping into creating the user interface forms for the Auto Rental data.

Indexes
For detailed information about indexes you can read the following: http://axwonders.blogspot.com/2011/11/indexes-in-microsoft-dynamics-ax.html
In a nutshell, we can say that a primary key is one or more columns that uniquely identify one record in a table from all the other records.  A primary index is a unique index for a table that defines the primary key for that table. To set an index as a unique index, set the index property Allow Duplicates to No. This is the same idea as creating a MS SQL table primary key (Check the following post for more info about this http://blog.sqlauthority.com/2008/09/08/sql-server-%E2%80%93-2008-creating-primary-key-foreign-key-and-default-constraint/).
NOTE: When a primary index is not specified, AX uses a Surrogate Key as the primary index. This key is the RecId field and, if the table is saved per company, the DataAreaId. The surrogate key is used on many relations between tables.
To set the primary index on a table, open the property sheet for the table. The PrimaryIndex property allows any unique index with a key that is mandatory and cannot be edited.

1.       In the AOT, locate the Eduardo_CustCarTable table.


2.       In the property sheet for the table, set the PrimaryIndex property on the table to RentalIdx






Parts
So, what are Parts? [From Microsoft - http://msdn.microsoft.com/en-us/library/gg844683.aspx ]A Part is a specialized type of control you use to retrieve and show a collection of data. A part specifies how to retrieve the data that appears in the FactBox pane of a form, the preview pane of a list page, or the enhanced preview of a control. You use parts to provide information related to a record that appears in a form…

…To create or modify a part, you use the properties of that part to describe how to retrieve and show data. For example, you use a part property to specify the data source for the part. Typically, you use a query as the data source for a part. You also use properties to specify the data fields that show when the part appears as a FactBox on a form.
Then a FactBox is the collection of data that appears on the form, which is based on a Part.  In addition, a FactBox always represents a single part, and if we want to modify a FactBox, we must modify the underlying part.
In AX 2012, a part is defined by using metadata and each part we create extends a common metadata model for parts. Further, one of the best advantages of the Part metadata model is that enables us to create parts that can appear in both the client and Enterprise Portal (EP).
Parts also allow us to represent data through cues in AX 2012. To show a cue in the FactBox pane of a form, you add the cue to a cue group part. A cue group is a type of part that contains one or more cues, and these can be created as a cue group that can appear in forms for both the client and EP, which can be used to add information to a role center page.
In my next and last post about this topic, we will create the user forms needed to display the Auto Rental data. In addition, we will create menu items, and of course a FactBox to display Auto Rental information related to a customer.


Take Care!