MB-500: Microsoft Dynamics 365: Finance and Operations Apps Developer
Lab 3: Implement the SysExtensionSerializer framework
Change Record
Version | Date | Change |
---|---|---|
1.0 | 23 Aug 2024 | Initial release |
Objective
This lab consists of several exercises.
Requirements include:
-
A working development virtual machine (VM) with access to the finance and operations apps and Microsoft Visual Studio.
-
A module and existing solution for development.
In the first exercise, you’ll use the SysExtensionSerializer framework to create three new text fields on the CustTable table, which supports the framework. The fields you’ll create on the linked table include:
-
Description1
-
Description2
-
Description3
In the second exercise, you’ll create the SysExtensionSerializer framework modifications for the CustTable form, and then in the third exercise, you’ll include the linked table into the CustCustomerV3Entity entity.
In the fourth and final exercise, you’ll test the modifications you’ve made for both the customer form and the CustomersV3 data entity.
Exercise 1: Implement the SysExtensionSerializer framework for a table
To implement the SysExtensionSerializer framework and create three new text fields for the CustTable table:
-
Open Visual Studio on your VM.
-
Create the solution you want to work with:
-
On Visual Studio 2019, select Continue without code
- Select Extensions > Dynamics 365 > Model Management > Create
Model
If ‘Feedback on Finance and Operations(Dynamics 365)’ screen pops up, select ‘Not Now’.
-
On Create model:
-
For Add parameters, enter these values and then select Next:
-
Model name: MB-500Lab3
-
Model publisher: Microsoft
-
-
For Select package, Create new package
-
For Select referenced packages, ensure the following are selected:
-
ApplicationFoundation
-
ApplicationPlatform
-
ApplicationSuite
-
Dimensions
-
Directory
-
PersonnelCore
-
-
Select Next until Configure your new project
-
-
On Configure your new project, enter these values, then select Create:
-
Project name: SysExtensionSerializerFramework
-
Solution name: MB500Lab3Sln
-
-
-
Right-click your project to open the context menu and select Properties.
-
Make sure the Synchronize Database property is set to True, and then select OK.
-
Right-click your project to open the context menu, and then select Add, and select Table.
-
Enter MB500CustTable as the name, and then select Add.
-
In View > Application Explorer, go to the search field, and then enter RefRecId in the Search field, and select Enter.
-
Navigate to the RefRecId Extended Data Type, and then drag it into the Fields node for the MB500CustTable table.
-
Select the RefRecId field, and then in Properties, select CustTable for the Name.
-
In Application Explorer, navigate to the Search field, enter Description, and then select Enter.
-
Navigate to the Extended Data Type Description, and then drag it into the Fields node for the MB500CustTable table.
-
Select the Description field, and in Properties enter the name Description1.
-
Drag the Extended Data Type Description into the Fields node for the MB500CustTable table, and then select the Description field.
-
In Properties, enter Description2 in the Name field.
-
Drag the Extended Data Type Description into the Fields node for the MB500CustTable table, and then select the Description field.
-
In Properties, enter Description3 in the Name field.
-
Navigate to the Indexes node at MB500CustTable in the Designer.
-
Right-click Indexes to open the context menu, and then select New Index.
-
In Properties, enter the following:
-
Name: CustTableIdx
-
Allow Duplicates: No
-
Alternate Key: Yes
-
-
Drag the CustTable field from the Fields node to the CustTableIdx node.
-
Navigate to the Mappings node for the MB500CustTable, right-click it to open the context menu, and select New Mapping.
-
In Properties, navigate to the Map property, and then select the drop-down arrow.
-
In the Search field, enter SysExt, and then select SysExtensionSerializerExtensionMap.
-
Navigate to SysExtensionSerializerExtensionMap in the Mappings node, and then expand SysExtensionSerializerExtensionMap.
-
Navigate to BaseRecId, and then in Properties, select the drop-down arrow by Map Field To.
-
Select the CustTable field, and then navigate to the Relations node for the MB500CustTable.
-
Right-click Relations to open the context menu, and then select New, and select Relation.
-
Set the following properties for Relation1:
-
Cardinality: ZeroOne
-
Name: CustTable
-
On Delete: Cascade
-
Related Table: CustTable
-
Related Table Cardinality: ExactlyOne
-
Relationship type: Composition
-
-
Right-click CustTable Relation to open the context menu, and then select New, and select Normal.
-
Set the following properties for the RelationConstraintField1 :
-
Field: CustTable
-
Related Field: RecId
-
-
Navigate to Properties for the MB500CustTable table, and then enter CustTableIdx for Replacement Key.
-
Navigate to the Methods node for MB500CustTable.
-
Right-click Methods to open the context menu, and then select Override, and select insert.
-
Change the logic in the insert method to the following:<pre>public void insert() { if (this.CustTable) { super(); } }
</pre>
-
Navigate to the Methods node on MB500CustTable, and then right-click Methods to open the context menu and select Override and update.
-
Change the logic in the update method to the following:<pre>public void update() { if (this.CustTable) { super(); } }
</pre>
- Select Save All, and then right-click the SysExtensionSerializerFramework project to open the context menu and select Build.
Exercise 2: Implement the SysExtensionSerializer framework for a form
To implement the SysExtensionSerializer framework for a form:
-
In Solution Explorer, select the SysExtensionSerializerFramework project.
-
In Application Explorer, navigate to the Search field, enter CustTable, and then select Enter.
-
Navigate to the User Interface node, and then select Forms.
-
Right-click the CustTable form to open the context menu, and then select Create Extension. The extension for the CustTable form is created.
-
In SolutionExplorer, Right-click the form extension for the CustTable form to open the context menu, and then select Open.
-
In Designer, navigate to Data Sources, and then right-click Data Sources to open the context menu, and then select New Data Source.
-
Enter the following properties for the DataSource1 data source:
-
Table: MB500CustTable
-
Join Source: CustTable
-
Link type: OuterJoin
-
Insert At End: No
-
Insert If Empty: No
-
-
In Design, navigate to Tab > TabPageDetails > TabHeader > TabDetails > Administration, and then navigate to the Fields node for the MB500CustTable data source.
-
Drag the following fields into the Administration group in the form design:
-
Description1
-
Description2
-
Description3
-
-
Select Save All, and then in the Application Explorer, navigate to the Search field.
-
Clear the Search field, and then select Enter.
-
Enter CustTable in the Search field, and then select Enter.
-
Navigate to User Interface > Form Extensions, find your form extension CustTable.MB500Lab3, and then navigate to the DataSources node.
-
Find the MB500CustTable data source, and then right-click it to open the context menu and select Create Code Extension.
-
Right-click the code extension class, such as CustTable_MB500CustTable_MB500Lab3_Extension, in the SysExtensionSerializerFramework project in Solution Explorer to open the context menu, and then select Open.
-
Create a chain of command for the init method:<pre>[ExtensionOf(formDataSourceStr(CustTable, MB500CustTable))] final class CustTable_MB500CustTable_MB500Lab3_Extension { /// <summary> /// Chain of command method which making extensionTablePair in standard CustTable form /// </summary> public void init() { next init();
FormDataSource MB500CustTable_DS = this; FormRun formRun = MB500CustTable_DS.formRun(); FormDataSource custTable_DS = formRun.dataSource(formDataSourceStr(CustTable, CustTable)); SysExtensionSerializerFormRunHelper::construct().addExtensionTablePair(CustTable_DS.cursor(), MB500CustTable_DS.cursor()); } }
</pre>
-
Navigate to User Interface > Forms in Application Explorer, and then find the CustTable form.
-
Navigate to the DataSources node, and then find the CustTable data source.
-
Right-click CustTable to open the context menu, and then select Create Code Extension.
-
Right-click the code extension class, such as CustTable_CustTable_MB500Lab3_Extension, in the SysExtensionSerializerFramework in Solution Explorer to open the context menu, and then select Open.
-
Create a chain of command for the write method:<pre>[ExtensionOf(formDataSourceStr(CustTable, CustTable))] final class CustTable_CustTable_MB500Lab3_Extension { /// <summary> /// CoC of CustTable_DS write method /// </summary> void write() { next write();
FormDataSource MB500CustTable_DS = this.formRun().dataSource(formDataSourceStr(CustTable, MB500CustTable)); if (MB500CustTable_DS) { CustTable custTable = this.cursor(); MB500CustTable MB500CustTable = MB500CustTable_DS.cursor(); if (SysExtensionSerializerExtensionMap::isExtensionEnabled(tableNum(MB500CustTable))) { MB500CustTable.SysExtensionSerializerExtensionMap::insertAfterBaseTable(CustTable); } } }
}</pre>
22.Select Save All, and then find the SysExtensionSerializerFramework project in Solution Explorer, right-click it to open the context menu, and then select Build.
Exercise 3: Update data entities when using the SysExtensionSerializer framework
To update data entities when you’re using the SysExtensionSerializer framework:
-
In Solution Explorer, select the SysExtensionSerializerFramework project, and then in Application Explorer, navigate to the Search field.
-
Enter CustCustomer in the Search field, and then select Enter.
-
Navigate to the Data Model > Date Entities node, and then find the CustCustomerV3Entity data entity.
-
Right-click the CustCustomerV3Entity data entity to open the context menu, and then select Create Extension.
-
Right-click the Extension data entity, such as CustCustomerV3Entity.MB500Lab3, in the SysExtensionSerializerFramework project in Solution Explorer to open the context menu, and then select Open.
-
In Designer, navigate to the Data Sources node, and then expand the CustTable data source.
-
Select Data Sources for the child data sources, and then right-click Data Sources to open the context menu and select New Data Source.
-
Enter the following on the new QueryEmbeddedDataSource1 data source properties:
-
Table: MB500CustTable
-
Join Mode: OuterJoin
-
Use Relations: Yes
-
-
Navigate to the Fields node on the MB500CustTable data source, and then expand the Fields node.
-
Right-click the Description1 field to open the context menu, and then select Copy.
-
Navigate down to the Fields node for the Data Entity extension, and then right-click it to open the context menu and select Paste.
-
Navigate to the Fields node for the MB500CustTable data source, and then expand the Fields node.
-
Right-click the Description2 field to open the context menu, and then select Copy.
-
Navigate to the Fields node at the Data Entity extension, and then right-click it to open the context menu and select Paste.
-
Navigate to the Fields node on the MB500CustTable data source, and then expand the Fields node.
-
Right-click the Description3 field to open the context menu, and then select Copy.
-
Navigate to the Fields node for the Data Entity extension, and then right-click it to open the context menu, and then select Paste.
-
Select Save All, and then in Application Explorer, navigate to Data Model and Tables.
-
Find the CustCustomerV3Staging table, and then right-click it to open the context menu and select Create Extension.
-
Right-click the table extension, such as CustCustomerV3Staging.MB500Lab3, in the SysExtensionSerializerFramework project in Solution Explorer to open the context menu, and then select Open.
-
Expand the Fields node in Designer, and then in Application Explorer, navigate to the Search field.
-
Enter Description, and then select Enter.
-
Navigate to the Extended Data Type Description.
-
Drag the Extended Data Type Description into the Fields node for the CustCustomerV3Staging.MB500Lab3 table extension.
-
Select the field Description, and then in Properties, enter Description1 in the Name field.
-
Drag the Extended Data Type Description into the Fields node for the CustCustomerV3Staging.MB500Lab3 table extension.
-
Select the Description field, and then in Properties, enter Description2 in the Name field.
-
Drag the Extended Data Type Description into the Fields node for the CustCustomerV3Staging.MB500Lab3 table extension, and then select the Description field.
-
In Properties, enter Description3 in the Name field, and then select Save All.
-
Find the SysExtensionSerializerFramework project in Solution Explorer, and then right-click it to open the context menu and select Build.
-
Right-click the project again to open the context menu, and then select Synchronize SysExtensionSerializerFrameform (USR) with Database.
Exercise 4: Test modifications from the SysExtensionSerializer framework
To test modifications:
-
Open Microsoft Edge on your VM, and then go to the Dashboard – Finance and Operations (dynamics.com) URL, and sign in to finance and operations apps.
-
In the Navigation Pane, expand Workspaces, and then select Data Management and select Framework Parameters.
-
Navigate to Entity Settings, and then select Refresh entity list. The entity list should now be updated with your modifications.
-
In Navigation Pane, expand Modules, and then select Accounts receivable.
-
Expand Customers, select All customers, and then select the first customer.
-
Select Edit for editing, and then in the Miscellaneous details FastTab, enter the following in the Description fields:
-
Description: Test1
-
Description: Test2
-
Description: Test3
-
-
Select Save and navigate to the Accounts receivable module, expand Customers, and then select All customers.
-
Select the first customer, and then verify the values in the three description fields.
-
Navigate to Settings (the gear on the top right), select User options, go to the Preferences tab, and change the Startup Company to USMF.
-
Open a new tab in Microsoft Edge on your VM, and enter the following URL: usnconeboxax1aos.cloud.onebox.dynamics.com/data/CustomersV3?cmp=USMF.
-
Select Enter, and then find rows 311 through 313 (this may vary slightly), and verify the values in the new fields for the data entity: