How To Create A Form In D365

Share this:

In this article I will show you how to create a form in D365. Users create new forms to allow users to enter data into the system, view existing data, and interact with the system. One of the first tasks needed, is to create a table to store the data. We covered how to create a table in Microsoft Dynamics 365 F&O in this previous article. Now we move on to creating the form itself. Using D365, Microsoft has provided an incredible tool for building forms very easily and quickly, while also allowing for in depth functionality. I will go ahead and start with a basic form.

Create A D365 Project And Solution

First, in your D365 environment, go to Windows Start and type ‘Visual Studio’. Right click on Visual Studio and select ‘run as administrator’. It is actually important when doing development that you run Visual Studio as administrator.

Select File>New>Project. In the dialog that opens, select Dynamics 365 on the left hand side. Then select Finance Operations as the project type.

Note: If you do not see this option, you most likely do not have this project type installed. I recommend working in a Life Cycle Services Development environment, which will already have this installed and setup.

Enter in a name for your project, and check the ‘Create directory for solution’ checkbox. You do not need to check the ‘Add to Source Control’ checkbox, but you can if you have already setup your source control.

Next, right click on your project, and select Properties. In the dialog that opens, set the ‘Model’ to your custom model, if you have one. Also set the ‘Synchronize Database on Build’ property to True. This is needed when creating or modify tables, so that the changes you make in Visual Studio get synched to the actual SQL Server Database.

This image has an empty alt attribute; its file name is image-1.png

Create A Form

Next I will show you how to create a form. Right click on your project, and select Add>New Item. In the dialog that opens, select ‘Form’, and provide a name for the form. In my example, I will call my form TutCar. Then press Ok.

In this tutorial we will create a very simple form that will allow us to view and add data to the table we created in the previous article. Double click on the form node to open up the form designer. It will look like this.

Empty Form Designer

Add A Data Source

Understanding Data Sources is usually the first step in learning how to create a form. The best way to read, insert, or update data on a form is to use a Data Source. A data source tells the form what data you want to work with. Then the system does the hard part for us. It handles running the sql code needed to read and write to the underlying table.

Likewise, Security and the sql connection string are also handled automatically. And the system stores the data in a Data Source object that we can easily interact with, within x++. This is one of the many ways using Microsoft Dynamics 365 F&O makes form creation so much easier for developers.

Open the Application Explorer window in Visual Studio. If you do not see it, select View>Application Explorer in Visual Studio. In the top search bar, search for the table you wish to use on the form. In this case, search for ‘Car’. If you followed the previous tutorial, you should see it under the ‘Tables’ node.

Next, click and drag the table from the Application Explorer window to the ‘Data Sources’ node in the Form Designer window.

The system will create a new Data Source under the Data Source node, with a name that matches the table.

Right click on the data source node ‘Car’, and select properties. In the Properties window you will see that the ‘Table’ property is set to ‘Car’. And the Name is set to ‘Car’.

Alternately, right click the ‘Data Sources’ node, and select ‘New Data Source’. Then open the properties windows for that node. And finally set the Name to ‘Car’, and the Table to ‘Car’. However, dragging the table to the Data Sources node does this automatically and is faster.

Set The Design Pattern

When learning how to create a form in D365, you need understand that each form should follow a Design Pattern as a Best Practice. Using a Design Pattern, helps users and developers in several ways. Below is just a few.

  • They ensure forms of a particular pattern follow a consistent structure. This helps end users understand how to use them from their past experience with other forms that use the same pattern.
  • They allow for certain form properties to be defaulted when developing the forms.
  • When Visual Studio is told what design pattern is being used, the system can provide a guided experience to assist with development.

To learn more about design patterns, and to understand how to identify which pattern your form should use, refer to this Microsoft documentation. In this case, we are looking to create a form with a basic grid. This fits the ‘Simple List‘ design pattern.

In the Form Design window, right click on the ‘Design’ node, and select ‘Apply pattern’>Simple List.

Visual Studio should now automatically show you the ‘Pattern’ tab in the windows below. But if not, you can always see this by selecting the Design node, and selecting the ‘Pattern’ tab.

Because you have selected a design patter, Visual Studio now is able to provide a guided experience of what nodes you need to add to your form to ensure it follows that pattern.

Add An Application Bar (Action Pane)

The Application Bar (Action Pane) is the bar at the top where form buttons should reside. This bar can take on different styles, including looking like a full Ribbon Bar. But the case of this pattern, the bar will be thin. And we actually no longer need to add buttons for ‘new’ and ‘delete’ as the system will show these automatically. We will only use this bar when we need to add additional buttons.

To add the Application Bar (Action Pane), right click on the ‘Design’ node and select ‘Action Pane’.

Note: The system will often end the name of the created node with the number 1. I recommend you remove this suffix to make the name cleaner. To do this, right click on the node that is created, and select Properties. Change the ‘Name’ property to not end with ‘1’.

Select the ‘Design’ node again, and the ‘Pattern’ tab. You will now see that the system no longer requires you to add the ‘Application Bar (Action Pane)’ node.

Add A Grid

One of the most common controls used when learning how to create a form, is the Grid control. Grid controls are connected to Data Sources, and allow fields on the underlying data source tables to be shown and updated. As well as new records to be inserted. What would otherwise take a lot of development, is quickly and easily done using a Grid control in Microsoft Dynamics 365 F&O.

Right click on the ‘Design’ node and select New>Grid.

A new grid control is created. Select the node. Right click and select ‘Properties’. In the Properties window, change the ‘Data Source’ node to ‘Car’. Or whatever your data source name is. Then in the ‘Data Group’ node, select ‘Identification’. Or the name of the Field Group on the table of your Data Source.

Setting the Data Group, automatically adds the needed controls to the grid for the fields that are part of that Field Group. This is very cool, and allows developers to create grids very quickly. If you do not have a Field Group on the table of your Data Source you can add one to your table.

After you add it to the table, save the table and form. Then right click on the form node, and select ‘Restore’. This will refresh the Data Source nodes, and the system will see the newly added Data Group. If you do not wish to use a field group, you can drag the fields directly from the data source node in the left window to the grid node on the right.

Add A Custom Filter Group

The Custom Filter Group on forms provide users a fast way of filtering the data that shows in the grid. On any grid in D365, users can select the column header, and filter the results, very similar to how users use Excel. The Quick Filter control inside a Custom Filter Group allows users to enter in a value, and then be prompted with which column they wish to filter. This serves as an even faster way of filtering the data in the grid. To make forms that much easier to use, it is a Best Practice to add a Custom Filter Group to a from that uses the Simple List form Pattern.

Right click on the ‘Design’ node, and select New>QuickFilter

Next, hold down Alt, and push the up arrow, to move the Group control above the ‘FormGridControl’. You can use the Alt key and arrow keys to move nodes up or down in the Form Designer tree structure.

Right click on the Group, and select Apply pattern>Custom and Quick Filters.

Nodes within forms are also allow to have what are called Sub Patterns. This again allows Visual Studio to provide guidance to Developers to help them build the forms. Visual Studio now shows the nodes that is expects to see within this group.

Add a Quick Filter Control

In order to follow the design patter for a Custom Filter Group, we will add a Quick Filter control. Right click on the Group, and select New>QuickFilter

Add a Quick Filter Control

The reason we created the Grid control first, is because the Quick Filter control needs to be pointed at another control, such as a grid, so it understands what columns it can show the user to filter.

Select the QuickFilterControl, right click and select ‘Properties’. In the ‘Properties’ window set the ‘Target Control’ to the name of your Grid Control. Optionally, you can set the ‘Default Column’ to be the column that will be filtered by default, without the user changing the selection. When this property is not set, the control will default to use the first column in the grid.

Set Quick Filter Properties

Validating The Form Follows Design Patterns

Now that all of the controls are added, let us make sure that we have followed the design patterns. Click on the Group and select the ‘Pattern’ tab. Make sure there is no red nodes, indicating you are not yet following the pattern.

Custom And Quick Filters patter validation

Similarly, select the ‘Design’ node, then the Pattern tab, to validate you have met all of the requirements of the Simple List design pattern.

This image has an empty alt attribute; its file name is image-30.png

Additional Nodes and Properties

Although we have finished adding the form nodes, there are still some additional properties that should be set on any form. As I have said, this article is not intended to cover everything relating to forms. However, I will cover some of the important properties.

After selecting the Design node, right click and select ‘Properties’. Then, in the Properties window, set the Caption, Data Source, and Title Data Source. The Data Source should be the primary data source on the form and is used to control what data source is primary affected when the Save, New, or Delete buttons are clicked. Finally, the Title Data Source will affect what field data is shown on the caption bar, and will use the title1 and title2 fields specified on the underlying table properties.

Also select the primary data source node, and view the Properties window. Often these properties are left alone. However, setting these properties can control whether users can create, delete, or edit data on this form.

Running The Form

Now, we get to the fun part: Running the Form! In order to run the form, we need to tell Visual Studio which object it should run. Right click on the form, and select ‘Set as Startup Object’.

Finally, click ‘Start’ in Visual Studio.

Clicking the Start button in Visual Studio

The system will build the solution, open a browser, and direct D365 to open this form. Moreover, Visual Studio will attach to the process, so that the form’s code can be debugged as well.

Running the form

Additional Types of Forms

To see how to create other types of forms, with different layouts, please see my other articles. Specifically, take a look at Simple List and Details Form in D365.

Conclusion

At this point, you have learned how to create a form in D365. Albeit, the form is very basic, but it is very common to need to grid a form like this. Form like these are often created to allow users to be enter data that can be used by other related tables and processes. Thanks to Microsoft Dynamics 365 F&O and Visual Studio, creating forms with buttons, filters, grids, and data sources is very easy. And requires a lot less work than in many other languages and systems. This allows developers to then focus on the functionality and business logic of their forms.

If there are areas you have questions on, or areas I missed please let me know. Similarly, if there are areas you would like me to to cover in more details, please let me know if the comments. Thank you so much for reading.

Peter Ramer
Peter Ramer is a part of the Managed Application Services team at RSM working on Microsoft Dynamics 365. He focuses on the Retail and Commerce industries. When he is not solving problems and finding ways to accelerate his clients' business, he enjoys time with his three kids and amazing wife.

Share this:

5 thoughts on “How To Create A Form In D365

Add yours

  1. Hi,

    I am facing an issue at applying pattern to form group.
    I cannot find the option “Custom and filter groups” rather just have the option “Custom”
    while working with Simple List pattern, hence facing an issue.

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑