Tuesday 24 October 2023

Data Entities in D365 FnO

 

Data management - Data entities

·       Data entity is a conceptual abstraction and encapsulation of one of more underlying tables.

·       Data entity represents a common data concept or functionality, for example, Customers or Vendors.

·       Data entities are intended to be easily understood by users familiar with business concepts. After data entities are created, you can reuse them through the Excel Add-in, use them to define import/export packages, or use them for integrations

A data entity represents a meaningful set of data. For instance, a data entity could be created for a customer that contains information from various database tables that define what a customer is, e.g., name, payment information, addresses, etc. A data entity organizes all this data in a way that’s convenient to handle and allows users to work with the entity itself to import or export data, rather than having to import or export individual tables.

 

Create a Data Entity in D365

Let’s create a data entity to handle exporting and importing item serial numbers using single database InventSerial.

 

·       Create a D365 project in Visual Studio named DataEntityExample. To create a new entity, right-click the project and then click Add > New item. The Add New Item dialogue box opens.

·       Select Data Entity, and then set the Name property to ItemSerialNumber. Then click the Add button.

 

Create a Data Entity in D365

 

In the Data Entity Wizard, all of the properties will be defaulted except Primary datasource. Select InventSerialtable as the primary datasource to export/import the item serial numbers. Click the Next button.

 

Create a Data Entity in D365 2

Add fields to the new entity from the data source InventSerial as shown in the following screenshot. Click the Convert labels to field names checkbox to generate names from the existing labels.

Create a Data Entity in D365

Click Finish. The newly created data entity and staging table are added to the project.

 

Create a Data Entity in D365

In Solution Explorer, right-click on the ItemSerialNumber data entity node and then click Open. Set the Labelproperty to Item Serial Numbers. This is the name that will get displayed in the data entity list.

To make the entity available in data management, the property Data Management Enabled should be set to Yesand the property Data Management Staging Table should be ItemSerialNumberStaging.

To make the entity available in an Odata scenario, the Public Collection Name and Public Entity Name will get defaulted, and the property Is Public should be set to Yes.

Create a Data Entity in D365

 

Now open the ItemSerialNumberStaging table in the designer. Staging tables are used in import/export scenarios to temporarily store the data being exported and imported. In many cases, staging tables are mapped 1:1 to an entity.



Note that the first four fields (DefinitionGroup, ExecutionId, IsSelected and TransferStatus) are the standard fields of a data entity staging table. The table also contains the data fields we selected while creating the data entity. Note that the data entity relations will be created automatically.

Create a Data Entity in D365

In Solution Explorer, right-click the project, and then click Properties. Set Synchronize database on build property to True.

Note:  Entities are created as views in Microsoft SQL Server, and staging tables also are added. Therefore, we must sync a database when we build entities.

 

Sunday 13 August 2023

SSRS Reports in D365 FnO

 

SSRS Reports

 

SSRS (SQL Server reporting services) - SSRS provides a tools and services to help you to create, deploy, and manage reports for your organization. By this programming features that enable you to extend and customize your reporting functionality.
It is a report generation software that is a part of Microsoft SQL Server.
It enables users to execute reports using a web interface or even as embedded reports in applications
by using a web services interface

 

 

Report Type & Designs

Report Types: In AX there are two types of Reports

·       Query Report

·       RDP Report


Query Report: We can create reports using AOT Query (static query). This approach is suggested when data is coming direct from tables.

RDP Report: RDP report involves business logic according to the requirement.  This logic may be calculations or getting values from different tables based on conditions.


Report Designs: Reports in AX are used to display data to users in a format which is suitable for the way that the information is read.
A report can have multiple designs so that the code can decide at run-time which design to use. The designs can be totally different, but they would share the same data sources and form methods.

There are two common design patterns

·       Auto Design

·       Precision Design


Auto Design: This report is automatically generated based on the query in the data sources of the report. It limits the possibilities for the developer as developer cannot make any changes in the design of report.

 

Precision Design: The developer has full control over the design, he can modify the design according to the requirement.

 

 

Report Nodes:

The purpose of each report items is described below:

·       Datasets: The report dataset retrieves data from the AOT query. All fields which are available in AOT query are shown in the report dataset which can be referred in the report design later on.

·       Designs: The design or layout of the report on which the data would be displayed after retrieving from AX.

·       Images: Any embedded images that you want to display on SSRS report.

·       Parameters: Report parameters which are to be displayed on SSRS report and user can filter the report based on those parameters.

 

 

Menu & Menu Items D365 FnO

 

 Menu & Menu Items

You can create menu & menu items to provide access to forms, reports, classes, jobs, and queries in Microsoft Dynamics 365.

There are 3 types of Menu Items:

Display Menu item - This object is used to contain menu items that reference runnable objects which are primarily for presenting data to the user such as forms.

Output Menu item - An output menu item should have the sole purpose to print a result, mostly used for referencing classes. Used for reports.

Action Menu item - As the name says it, you should create a menu item under this folder for your runnable object has an action to perform, for example creating or updating data.

So choosing between these three is on the developer’s sole discretion and I hope now you’ll be able to make a better choice for your scenario. A basic thumb rule is:

Display – for Form
Output – for Report
Action – for classes

Important Properties of Menu
Label
Menu Item Name
Menu Item type

Important Properties of Menu Items
Name
Label
Object
Object Type

 

 

From Methods

 

Forms Method

These methods are used to retrieve and validate calling parameters. Do not write any code that effects the database.

Example: Change properties of control, Like Visibility, Enable, Editable.

·       init () - These methods are used to retrieve and validate calling parameters, Change properties of control, Like Visibility, Enable, Editable

·       run ()

·       close ()

 

Forms Data Source Method

These methods are used to perform operation on database fields. And also for improving performance by clearing cache data.

Also used for Sorting, filtering and creating ranges.

Example: Set Datasource properties – AllowEdit, AllowCreate, AllowDelete.

·       Init () - These methods are used to perform operation on database fields. And also for improving performance by clearing cache data. Set Datasource properties – AllowEdit, AllowCreate, AllowDelete.

·       Executequery() – This method is frequently used for applying ranges and filters.

 

·       Active () – Updating design depending on selected records, updating other datasource queries.

·       Create() – Add supplementary rules to validate the creation. Example while creation of record open some new form to enter values.

·       Initvalue() – Assign default value

·       Validatewrite () – Validate business rules and data consistency. Example mandatory fields that are form specific.

·       Write () – Override the normal saving process with specific rules. Updating datasource in same form.

 

 

 

Form Method Calling Sequence

 

Sequence of Methods calls while opening the Form

Form --- init ()
Form --- Datasource --- init ()
Form --- run ()
Form --- Datasource --- execute Query ()
Form --- Datasource --- active ()

 

Sequence of Methods calls while closing the Form

Form --- canClose ()
Form --- close ()

 

Sequence of Methods calls while creating the record in the Form

Form --- Datasource --- create ()
Form --- Datasource --- initValue ()
Table --- initValue ()
Form --- Datasource --- active ()

 

Sequence of Method calls while saving the record in the Form

Form --- Datasource --- ValidateWrite ()
Table --- ValidateWrite ()
Form --- Datasource --- write ()
Table --- insert ()

 

Sequence of Methods calls while modifying the fields in the Form

 

Table --- validateField ()

Table --- modifiedField ()

 

 

 

 

FormRun formRun = sender.formRun() as FormRun;

You can even call custom methods
formRun.myCustomMethod();

Get the selected datasource record
TableName tableBuffer = sender.cursor();

Get datasource variable
FormDataSource salesTable = sender.formRun().dataSource(SalesTable);

 

Edit Property

salesTable_ds.object(fieldNum(SalesTable, SalesId)).allowEdit(allowEdit);

 

Get Value

salesTable_ds.object(fieldNum(SalesTable, SalesId)).getValue();

 

Set Value

            salesTable_ds.object(fieldNum(SalesTable, SalesId)).setvalue(“Pass your value”);

 

Enable/disable a control

DataSourceName_ds.object(fieldnum(Table, Field)).visible(true/false);

 

Make a control mandatory

DataSourceName_ds.object(fieldnum(Table, Field)).mandatory(true/false);

 

 

Create new form D365 FnO

                                                             Create new forms

Create the form

·       Right click on project and add new form “MyNewForm” in your project, a form is added to the project. Open the project to see designer

·       Add a Data Source to the Form, Expand MyNewForm so that the Data Sources and Designs nodes are visible. Drag Sales Table onto the Data Sources node of the form.

·       You can also create a form data source by right-clicking the Data Sources node of MyNewForm, and then clicking New Data Source. Use the Table property to select Sales Table.

Form controls belong to one of three groups, depending on their data source as follows:

·        Bound control – associated with a field in an underlying table. Use bound controls to display, enter, and update values from fields in the database.

·        Unbound control – does not have a data source. Use unbound controls to display pictures and static text.

·        Calculated controls – uses a method as the data source. An example of a calculated control is the sum of two fields on a form.


Add a control and fields to the Form

·       Right click the Design node of MyNewForm. In the properties window, click Caption and type Sales. The value in the Caption property appears in the title bar of the form.

·       Click Title Datasource and select salesTable from the drop-down list.

·       Right-click Design, click New Control, and then click Grid.Click the grid in the Design node. In the Properties window, click Width and select Column width. Click Height and select Column height.

·       Expand the Data Sources > SalesTable > Fields node of MyNewForm.

·       Press Ctrl and then click AssetId, Name, SerialNum, and Model. Drag the highlighted fields to the Grid in the Design node of MyNewForm.

 

Add a Button to the Form

·       Right-click Design, click New Control, and then click Button.

·       In the Properties window, click Text and type Sales order.

·       Expand the node for the new button, right-click Methods, click Override method, and then click clicked.

·       Right-click the clicked node, and then click View Code. The clicked method opens in the code editor.

 

 

Add the action pane

·       Go to Designs in forms, right-click Design, point to New Control, and then click ActionPane. An action pane control is added to the Design node of the form.

·       Properties

Name - Enter a name that identifies your action pane.

Style - Standard

Vertical Spacing - 0

Width - Column width

Add an action pane tab

·       Right-click the action pane control, point to New Control, and then click ActionPaneTab. An action pane tab control is added to the action pane.

·       Properties

Name - Enter a name that identifies your action tab.

Caption

Add an action pane button group

·       Right-click the action pane tab, point to New Control, and then click ButtonGroup. A new button group control is added in the AOT.

 

Add an action pane button

·       Right-click the button group control, point to New Control, and then click the type of button you want to add to the group. The new button is added to the button group.

·       For example, you click CommandButton to add a button that performs a specified Microsoft Dynamics AX command.

 

 

 

 

Data Entities in D365 FnO

  Data management - Data entities ·        Data entity is a conceptual abstraction and encapsulation of one of more underlying tables. ...