Search Suggest

October 2022

what-is-a-model-in-D365-FO-and-how-to-create-a-model-in-D365-FO
As we know, the complete D365 Finance and Operation developments are based on these four terminologies Package, Model, Project, and Element. So as a developer you need to know processes how to create a model, how to update a model, and how to delete a model.

What is a Model in D365?

A model is a design-time concept. A particular model can contain multiple Visual Studio projects. Therefore, you can say it is a collection of projects and a single project can have all or subset of elements from originating model. 

However, the association of a project is only with a single model. It is basically a unit of development/customization. Metadata for models is stored locally on an XML file called a descriptor XML. Hence creating a model is a mandatory thing for any sort of customization.

A model is a group of elements, such as metadata and source files, that typically constitute a distributable software solution and includes customizations of an existing solution. A model is a design-time concept, for example, a warehouse management model or a project accounting model. A model always belongs to a package. A package is a deployment and compilation unit of one or more models. It includes model metadata, binaries, and other associated resources. One or more packages can be packaged into a deployable package, which is the vehicle used for deployment in runtime environments.

Suppose you have a requirement for developing or customizing a payroll solution, so what you will do? in this case, before starting the project or coding you have to create a model, you need to give a name for the model such as Payroll Model, then further all your customization or anything associated with this payroll solution development or any object you are creating as new such as Tables, Forms, EDT, Reports, etc… or extending already existing objects like CustTable, VendTable or anything will be based on the model  Payroll Model.

But here you don’t confuse the d365 model concept with the dot net c# model concept, that is another concept.

Where is Model Data Stored in D365?

Where is D365 Model Data Stored? In Visual Studio while we are creating a model or updating a model one new folder is created, and some files are in the AOSService folder, which contains the files to run Microsoft Dynamics 365 for Finance and Operations. In a cloud-hosted developer machine, you can look on the C drive, and find your new model folder under C:\AosService\PackagesLocalDirectory\<Your model Name>

Model = Collection of Components inside a Solution.

model-managment-in-d365


How to Create a model in D365?

Here I put some basic steps for creating a model in d365 using visual studio, in the next following articles I will show you how to create, update and delete a model. So how to create a model in d365?

To create a new model, follow these steps:

1. Open Visual Studio as admin.

2. On the Dynamics 365 menu, point to Model Management and select Create model

3. Give a model, publisher name, and other values

This is the basic way of creating a model in D365.

For example, here I created one model named D365SnippetModel,

What is a model in D365FO and how To create a model in D365FO


How to update a model in D365?

During the creation of a model, if any reference to any package is missed then it can be added through the Update Model parameters wizard. Here, I am trying to add the package Application Suite to the model Sample (created earlier).

Suppose you have created a model, the initial time you forgot or not added the reference packaged Ledger, while you are proceeding with project customization, you need to use the EDT object named AccountCategory, so in this case, you must update the model parameters, otherwise what will happen? visual studio will show some errors and you cannot proceed with the project. O in this case you follow these steps, 

Step 1: Launch the Update model parameters wizard (through path Dynamics 365 > Model Management > Update model parameters....).

Step 2: On the Update Model parameters page, select the required model in our example I have chosen the name to be Payroll Model. Click on Next.

Step 3: On the Select referenced packages page, select package in our case Ledger. Click on Next.

Step 4: On the Summary page, provides a brief glimpse of model details like model description, referenced packages, and so on.

How to delete a model in D365?

If you no more need a model in d365, you can delete the model. This is an easy process in d365. Before deleting a model, you must stop following services

Stop the AOS web service and Stop the Batch Management Service.

you can delete your model easily by deleting the model folder in this path below path "C:\AOSService\PackagesLocalDirectory”. after deleting the model, you need to refresh the models to reflect the changes in your d365 project, for this you go to,

Dynamics 365 menu, point to Model management and select Refresh models,

then finally you must synchronize the database.

In the next following articles, I will explain the above 3 activities create, update & delete operations associated with a model individually with examples. If this article helps you, please try to share your comment.

In the previous article, I already showed the very simplest type of lookup in D365 FO, which was EDT lookup, for making an EDT type lookup, a developer does not need to worry more about writing x++ coding. In this tutorial, we are going to make a custom lookup using x++ for form in D365FO.

What is a lookup in D365 FO? 

Lookups are the standard way to display a list of possible selection values to the user. For a user, while editing or creating database records, a lookup makes the data entry easy and errorless. In Microsoft dynamics 365 finance and operations, there are many ways of creating lookups. 

Normally, standard lookups are created automatically by the system in Dynamics 365 for Finance and Operations and are based on the extended data types and table setup. They are based on table relations and appear automatically. No additional modifications are required. 

How to create lookup in D365FO using X++

Why Use a Lookup Method? 

Normally a look-up is used to list the master data in the system like customer master, vendor master, item master, etc. what will happen if a user is typing these values instead of selecting the values from the lookups. 

Consider a supplier order form, there we can select the vendor account using a lookup. Instead of selecting a vendor account using lookup, if the user is trying to type the vendor account details there are many chances to get an error in the input because the user doesn’t know the vendor account which are existing in the database. Also, while selecting a vendor from the lookup, a user can confirm the vendor by checking the other lookup columns which display all the details about the vendor. So, about a user, while editing or creating database records, a lookup makes the data entry easy and errorless. 

Suppose we have a requirement to display AccountNum, CustGroup, BankAccount, and PaymMode of all customers under the selected company. 

For this, you must follow the below steps.

How to create a custom lookup using X++ in D365FO?

1. Create a form

So, the first step is we need to create a form, for this

Right Click on Project Name > Add > New Item > User Interface > Form

here I created a form with name FrmCustomLookUp as shown in the figure.

How to create lookup in D365FO using X++

2. Open the Form

Once you created a new form, it will automatically open the designer window. Otherwise, you double-click on the form, and it will open in the designer window as shown below,

How to create lookup in D365FO using X++

3. Create a form Control String

Here we need to create a form string control on which you want to show the lookup. So create control of type “String” (“Traditionally it is StringEdit Control”) under the form. 

For this,

Right-click on the Design Node > New > String This actually creates a drop-down text box on which you want to show the lookup.

How to create lookup in D365FO using X++

Now the design part is over, next we have to write the x++ logic to create a lookup and add this look-up to the text box we already created under the form.

4. Add event handler method

For this, Expand the Events node under the formStringControl > Select OnLookup> Select Copy event handler method as shown in the figure.

How to create lookup in D365FO using X++

Then create a new class, here I created a class with the name CustomLookUp and paste the event handler method in Between the opening-closing brackets of the class, and paste the event code, we copied the code in the previous step.

How to create lookup in D365FO using X++

How to create lookup in D365FO using X++

You can copy and paste the below code snippets directly to your class.


class CustomLookUp
{
   
   
       [FormControlEventHandler(formControlStr(LookUpFrm, FormStringControl1), FormControlEventType::Lookup)]
       public static void FormStringControl1_OnLookup(FormControl sender, FormControlEventArgs e)
       {
           Query query = new Query();
           QueryBuildDataSource queryBuildDataSource;
           QueryBuildRange queryBuildRange;
           SysTableLookup sysTableLookup;
           sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable),sender,true);
           sysTableLookup.addLookupField(fieldNum(CustTable,AccountNum ));
           sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
           sysTableLookup.addLookupField(fieldNum(CustTable, BankAccount));
           sysTableLookup.addLookupField(fieldNum(CustTable, PaymMode));
           queryBuildDataSource = query.addDataSource(tableNum(CustTable));
           sysTableLookup.parmQuery(query);
           sysTableLookup.performFormLookup();          
     
       }
   
 
}

The four lines below add the four fields in the lookup and you will see AccountNum, CustGroup, BankAccount, and PaymMode in the lookup. So, you can also add more lookup fields in the lookup as per your requirement.

sysTableLookup.addLookupField(fieldNum(CustTable,AccountNum ));
sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
sysTableLookup.addLookupField(fieldNum(CustTable, BankAccount));
sysTableLookup.addLookupField(fieldNum(CustTable, PaymMode));

This is just an example shown to you. You can use the table and the fields as per your own requirements about How to create a lookup in D365FO using X++. If this helps you and you have learned something, please share.

Output

Right-click on the form FrmCustomLookUp and set this form as StartUpObject, then after the successful build of the project, run the project, you can see the below output.

How to create lookup in D365FO using X++

All the tutorials are for beginners, if you don't have a virtual machine for your learning purposes you can use Microsoft's free Virtual machine. if this tutorial is useful, please share it with others.

Happy coding with D365 Snippets

Related Tags

How to create a custom lookup using X++ in D365FO?
How many kinds of lookups can be made and how in D365? 
How do I create a lookup field in Dynamics 365 CRM?
How do I create a custom sequence number in D365FO? 
What is COC in D365FO?
systablelookup.add lookup method in d365 
multi select lookup in d365 finance and operations 
EDT lookup in d365fo 
override lookup method in d365 lookup 
the event handler in d365 more than one form was opened at once for the lookup control. lookup field in dynamics 365 x++ table field lookup
How many kinds of lookups can be made and how in d365?
EDT lookup in d365fo
lookup method in d365fo x++ 
systablelookup.add lookup method in d365
addlookupmethod x++
edt lookup in d365fo 
d365fo coc lookup
how to create a lookup field in dynamics 365

How to create a lookup in D365FO using X++?

Lookups are the standard way to display a list of possible selection values to the user. For a user, while editing or creating database records, a lookup makes the data entry easy and errorless. In Microsoft dynamics 365 finance and operations, there are many ways of creating lookups.

EDT and Table Relation Type lookups are the simplest forms of lookups in Microsoft dynamics 365 finance and operations.

In this article, I will describe the very simplest type of lookup, which is EDT lookup, for making an EDT type lookup, a developer does not need to worry more about writing x++ coding, 

Normally, standard lookups are created automatically by the system in Dynamics 365 for Finance and Operations and are based on the extended data types and table setup. They are based on table relations and appear automatically. No additional modifications are required.

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

Why Use a Lookup Method?

Normally a look-up is used to list the master data in the system like customer master, vendor master, item master, etc. what will happen if a user is typing these values instead of selecting the values from the lookups.

Consider a supplier order form, there we can select the vendor account using a lookup. Instead of selecting a vendor account using lookup, if the user is trying to type the vendor account details there are many chances to get an error in the input because the user doesn’t know the vendor account which is existing in the database. Also, while selecting a vendor from the lookup, a user can confirm the vendor by checking the other lookup columns which display all the details about the vendor. So, about a user, while editing or creating database records, a lookup makes the data entry easy and errorless.

Setting Up an EDT Lookup

If you are a beginner use Microsoft's free VM, where you can access both the Technical and Functional environments.

In this example, I am considering the standard EDT CustAccount  which is already available in the system. 

For this,

Open Application Explorer > Data Types > Extended Data Types.

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

Search the EDT CustAccount, Right click and select the open designer menu, then the EDT will open in the designer window as shown below.

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

Expand the Table Relation Node, there you can see one table relation which is,

CustAccount == CustTable.AccountNum

If we are assigning this EDT CustAccount into the newly created field your Table, automatically customer account number is populated in the field. The newly created field is based on EDT CustAccount and therefore, it automatically inherits its relation. So the field will list the Customer Account details which are available in the system for the selected company.

Suppose we are creating a table TbleSalesMen with three columns SalesManId, SalesManName, and CustAccountNum as shown in the figure.

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

Where you are assigning EDT CustAccount to the Extended Data Type Property of the field CustAccountNum as shown in the figure.

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

After the successful build of the project, right-click on the table TblSalesMen, select the Open Table Browser menu

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O


How it works...

The newly created CustAccountNum field is based on EDT CustAccount and therefore, it automatically inherits its relation. 

Output

How to Create Auto Lookup Using EDT with Table Reference in D365 F&O

Related Tags

How many kinds of lookups can be made and how in d365?
EDT lookup in d365fo
lookup method in d365fo x++ 
systablelookup.add lookup method in d365
addlookupmethod x++
edt lookup in d365fo 
d365fo coc lookup
how to create a lookup field in dynamics 365

In Microsoft Dynamics 365 Finance and Operations, the layer system is used to manage application components in a predefined order. USR layer is the highest layer and SYS is the lowest layer. The purpose of layers is to give developers the option to modify Microsoft's code but only in one of the layers that the developer has access to.

Understanding Layers in Dynamics 365 Finance and Operations

The following table shows all layers and associated usage:

USR - The user layer is for user modifications, such as reports. 

CUS - The customer layer is for modifications that are specific to a company. 

VAR - Value Added Resellers (VAR) can make modifications or new developments to the VAR layer as specified by the customers or as a strategy for creating an industry-specific solution. 

ISV - When an Independent Software Vendor (ISV) creates its own solution, its modifications are saved in the ISV layer. 

SLN - The solution layer is used by distributors to implement vertical partner solutions. 

FPK - The FPK layer is an application object patch layer reserved by Microsoft for future patching or other updates.

GLS - When the application is modified to match country or region-specific legal demands, these modifications are saved in the GLS layer.

SYS - The standard application is implemented at the lowest level, the SYS layer. The application objects in the standard application can never be deleted.

The bottom layer would be the SYS layer, which is where the standard application code resides and is accessible only to Microsoft. Other layers like ISV (Independent Software Vendor) and VAR (Value Added Reseller) can be accessed by providing keys provided by Microsoft for each layer except USR (User) which does not need a key.

Three Tier Architecture in Dynamics 365 Finance and Operations - Online Training Course Part 3

From the client environment (normally a Browser) request is sent to the AOS server. AOS server stands for Application Object Server will process this request. So, all requests and responses are processed from the AOS environment. If required, this AOS is communicated with the Database server, and finally processed response is sent back to the client. This is the normal Three tier architecture followed by D365.

Three Tier Architecture in Dynamics 365 Finance and Operations - Online Training Course Part 3



Every article written here is mainly targeted at beginners. If you are a beginner or planning your career with Dynamics 365 finance and operations, these articles are for you.

In the coming sessions, we must practice more to get a clear picture of the concepts. So, we need to configure the technical and functional environments, 

If you are a beginner don't worry about the technical and functional environments, all the practical sessions we covered through this training sessions are by using Microsoft's free Lab. There you can set up an online Virtual Machine for D365 F&O for Technical and Functional learning purposes Freely. Microsoft provides a VM Mode for a free, web-based virtual machine environment for D365 F&O Learners. 

Read this Article: How to Set Up a Free Virtual Machine for Dynamics 365 Development 

What is Microsoft Dynamics 365 Finance and Operations - Online Training Course Part1

What is Microsoft Dynamics 365

Microsoft Dynamics 365 is a cloud-based business Applications platform that combines customer relationship management (CRM) and Enterprise Resource Planning (ERP) which was announced by Microsoft in July 2016 and released on November 1, 2016. Along with CRM and ERP applications, Microsoft integrates business intelligence tools that can improve the productivity of any organization. 

Benefits of Dynamics 365

There are a lot of benefits while implementing Dynamics 365 in an organization, if you need more about the benefits of Dynamics 365, you can explore it through Google.

Cost-effectiveness

Dynamics 365 for Finance and Operations helps you identify redundant resources in your organization and reduce operational costs through automation and optimization. It is very easy to customize and integrate different components and modules of your ERP system and business.

Integration with other Microsoft products

The biggest benefits of Dynamics 365 are, the tight integration with other Microsoft products like Office 365, Azure, etc. Power BI can be easily integrated with D365 with simple steps and configuration. Data Entities are used for importing and exporting data, which can be easily created by users. 

User-friendly interface

Dynamics 365 offers a very friendly and easy-to-use user interface. Users will quickly learn and familiarize themselves with the software. Each user can focus on their work and become more productive in their daily activities. This applies to every user, even if they handle routine transactions with managers working on reports. Dynamics 365 for Finance and Operations provides a straightforward and user-friendly intuitive user interface. Combined with a personalized activity-based workspace, users can manage assets and processes more effectively and in real time.

Enhanced analytics & artificial intelligence

Dynamics 365 for Finance and Operations gives you access to enhanced analytics, allowing you to better analyze reports, provide real-time visibility into your operations, and build data faster. 

Powered by Microsoft Power BI, it also benefits from an embedded analytical workspace. This workspace enables you to design and distribute reports available in Dynamics 365 through a form extension. 

Dynamics 365 for Finance and Operations lets you close the books faster, improve cash flow, and simplify global financial management with sophisticated machine learning. You can receive deep, data-driven insights into user behaviors, establish meaningful customer relationships, and digitally transform your business. 

By using proactive guidance for finance management and predictive recommendations, you can engage in product innovation and increase profitability.

It can be hosted locally or can use the Microsoft cloud platform, Microsoft Azure. A minimum of 16 GB of RAM and 2 CPU Cores are required, more RAM and CPU cores increase the speed of compilation. This is the basic requirement for running a Dynamics 365 application.

Development system requirements for Microsoft Dynamics 365 Finance and Operations - Online Training Course Part2

Development environments can be hosted locally or on Microsoft Azure. The build process, X++ compilation, and generation of cross-reference information typically run satisfactorily on machines with 16 GB of memory and two CPU cores. The compiler uses available resources, so more RAM and more cores will speed up compilation, especially if there is contention for resources from other concurrent processes. If you run concurrent processes, we recommend 24 GB of memory with four cores. A minimum of two CPU cores is recommended because the developer environment contains many components running simultaneously. Components include AOS Web Application, Visual Studio, Management Reporter, and SQL Server. 

Development system requirements for Microsoft Dynamics 365 Finance and Operations? - Online Training Course Part2