Common Data ServiceDynamics 365 for Finance and Operations

F&SCM Customer Integration Through CDS (Common Data Service) for Apps

F&O Customer Integration Through CDS (Common Data Service) for Apps

In one of the implementation projects recently, we used the F&SCM (F&O) customer integration through CDS capabilities, available as a feature in the Common Data Service (CDS). Data Integration projects or data integrator (for administrators) is a framework ( available as part of the Common Data Service data integration) that is used to facilitate the integration of data between Dynamics 365 for Finance and Operations (Fin&SCM, also known as F&O) and Dynamics 365 for Sales.

F&SCM(F&O) Customer Integration Through CDS

Through Power Query or M based queries, there can be other sources of data, too, that can be connected to for data integration. In this case, we are mapping accounts in Sales with customers in FinOps.

Setup Data Integration projects:

The prerequisite to setup Data Integration projects is to first set up the connection sets. Connection sets are the framework through which various sources of data can be connected to. For example, in the connection set below, we have set up a connection set that will facilitate integration of data between accounts in Dynamics 365 for Sales and customers in Finance and Operations. Ensure that the connection sets point to the right legal entities.                                                                                           Fig 1 – Connection Sets

After setting up the connection sets, set up the data integration projects and ensure that the mapping is set up properly. Also, ensure the field mapping setup properly once the data integration is set up accurately.


The scenario is to map accounts in Sales to customers in FinOps. In addition to this, the addresses and contact details of these accounts in Sales are mapped with the primary address or the primary contact type in FinOps. The other requirement is to have the ability to create non-primary addresses and non-primary contacts in FinOps. Data integration projects leverage the Data Management capabilities of FinOps to manage data integration. This also means that various data entities from the data management framework are triggered in FinOps. In this case for customers the data integration entity that is triggered is CustCustomerV3Entity.

Note:The integration entity in CDS that is used for Customers is CustCustomerV2Entity. One needs to delete the CustCustomerV2Entity under Data Management -> Data Entities. The Data Entity CustCustomerV2Entity needs to be deleted first and explicitly add CustCustomerV3Entity (as on Platform Update 31).

LogisticsPostalAddress Code:

Override the post-event handler to edit non-primary addresses after the address is created. In case of LogisticsPostalAddress, following is the X++ Code to edit the details in the grid control.

[PostHandlerFor(formStr(LogisticsPostalAddress), formMethodStr(LogisticsPostalAddress, updateControls))]
public static void LogisticsPostalAddress_Post_updateControls(XppPrePostArgs args)
FormRun sender = args.getThis();

//Retrieve the two form data sources used in LogisticsPostalAddress form
FormDataSource logisticsPostalAddress_ds, logisticsLocation_ds;
FormDataObject IsPrimaryDet;
LogisticsPostalAddress logisticsPostalAddress;
DirPartyLocationRole dirPartyLocationRole;

LogisticsLocation logisticsLocation;
DirPartyLocation dirPartyLocation;
CustTable custTable;

logisticsPostalAddress_ds = sender.dataSource("LogisticsPostalAddress");
logisticsLocation_ds = sender.dataSource("LogisticsLocation");

//LogisticsPostalAddress and logisticsLocation details retrieved
logisticsPostalAddress = logisticsPostalAddress_ds.cursor();
logisticsLocation = logisticsLocation_ds.cursor();

//Retrieve the location details
select firstonly dirPartyLocation
where dirPartyLocation.Location == logisticsLocation.RecId;

//Retrieve the customer details from the address grid
custTable = CustTable::findByPartyRecId(dirPartyLocation.Party);

//Check if the customer record is externally maintained
if(custTable && custTable.IsExternallyMaintained)
//Validate if the address is non-primary
//Edit the Postal Address details like City, State, Zip Code
//Edit the name or description details in the Address

//Enable the purpose group
//IsPrimary toggle control disabled for non-Primary addresses




LogisticsElectronicAddress Code:

[FormDataSourceEventHandler(formDataSourceStr(LogisticsContactInfoGrid, LogisticsElectronicAddress), FormDataSourceEventType::SelectionChanged)]
public static void LogisticsElectronicAddress_OnSelectionChanged(FormDataSource sender, FormDataSourceEventArgs e)
LogisticsElectronicAddress LogisticsElectronicAddress;
LogisticsLocation logisticsLocation;
DirPartyLocation dirPartyLocation;
CustTable custTable;
FormRun element;
FormControl advancedButton, deleteContactInfoButton;

// Retrieve the form buttons
element = sender.formRun();
advancedButton ="DetailContactInfo");
deleteContactInfoButton ="DeleteContactInfo") ;

// Retrieve the datasource fields objects
FormDataSource LogisticsElectronicAddress_ds = sender.formRun().dataSource("LogisticsElectronicAddress");
FormDataObject typeObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, Type));
FormDataObject LocatorObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, Locator));
FormDataObject LocatorExtensionObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, LocatorExtension));
FormDataObject DescriptionObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, Description));
FormDataObject CountryRegionCodeObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, CountryRegionCode));
FormDataObject IsPrimaryObject = LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, IsPrimary));

// Retrieve customer record from the LogisticsElectronicAddress grid record
LogisticsElectronicAddress = LogisticsElectronicAddress_ds.cursor();
logisticsLocation = LogisticsLocation::find(LogisticsElectronicAddress.Location);
select firstonly dirPartyLocation where DirPartyLocation.Location == LogisticsLocation.RecId;

if (dirPartyLocation)
custTable = CustTable::findByPartyRecId(dirPartyLocation.Party);

// If the customer is externally maintained
if (CustTable && CustTable.IsExternallyMaintained)

// if contact information is not primary, make the fields in the grid editable

// if contact information is primary
// disable the advanced button so users cannot edit details in that screen

// disable the delete button

Configuration Keys:

LedgerBasic is the configuration key that’s required for CustCustomerV3Entity to be enabled. This is enabled (by default) in Dynamics 365 for Finance and Operations.

GitHub link:

The code repository is uploaded on github and following is the link to the Visual Studio Project.

The project resides on the var layer.

A model file is also uploaded on github. Import the model and build the model and the project. The model file name is: D365DMOSamples. Use the command line to import the model file.
Model File Name: D365DMOSamples

Command to Import the model file. This following step has to be executed before building the model and the project.  In this case, i have chosen C:Model_Backups as my source directory for the model file.

                                                                        Fig 2 – Import Model files


Disclaimer: The Questions and Answers provided on are for general information purposes only. We make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose.

What's your reaction?

In Love
Not Sure
Navneeth Nagrajan
Navneeth Nagrajan is a Technology Specialist at Deloitte Australia focussing on design, development, integration, and implementation of the Microsoft Power Platform (primarily PowerBI, Common Data Service and Flow) and Dynamics 365 for Finance and Operations ERP. Other areas of focus include Azure DevOps, Github (related to Dynamics 365 for Finance and Operations deployments), and Dynamics Lifecycle Services. Profile: Twitter: LinkedIn:

You may also like

Comments are closed.