通過應用程序的 CDS(通用數據服務)進行 F&SCM 客戶集成

Avilas

在最近的一個實施項目中,我們使用了通過 CDS 進行 F&SCM (F&O) 客戶集成功能,作為 Common Data Service (CDS) 中的一項功能提供。數據集成項目或數據集成器(適用於管理員)是一個框架(作為 Common Data Service 數據集成的一部分提供),用於促進 Dynamics 365 for Finance and Operations(Fin&SCM,也稱為 F&O)和 Dynamics 365 for Sales 之間的數據集成。

通過 Power Query 或基於 M 的查詢,還可以連接其他數據源以進行數據集成。在本例中,我們將銷售中的帳戶與 FinOps 中的客戶進行映射。

設置數據集成項目:

設置數據集成項目的先決條件是首先設置連接集。連接集是可以連接各種數據源的框架。例如,在下面的連接集中,我們設置了一個連接集,該連接集將促進 Dynamics 365 for Sales 中的帳戶與 Finance and Operations 中的客戶之間的數據集成。確保連接集指向正確的法律實體。圖 1 – 連接集

設置連接集後,設置數據集成項目並確保正確設置映射。此外,一旦數據集成準確設置,請確保字段映射設置正確。

設想:

該場景是將 Sales 中的帳戶映射到 FinOps 中的客戶。除此之外,Sales 中這些客戶的地址和聯繫方式會與 FinOps 中的主要地址或主要聯繫人類型進行映射。另一個要求是能夠在 FinOps 中創建非主要地址和非主要聯繫人。數據集成項目利用 FinOps 的數據管理功能來管理數據集成。這也意味著來自數據管理框架的各種數據實體在FinOps中被觸發。在這種情況下,對於客戶來說,觸發的數據集成實體是Cust客戶V3實體

筆記:CDS 中用於客戶的集成實體是Cust客戶V2實體。需要刪除一個Cust客戶V2實體在下面數據管理->數據實體。數據實體Cust客戶V2實體需要先刪除並顯式添加Cust客戶V3實體(如平台更新 31 所示)。

物流郵政地址代碼:

創建地址後,重寫事件後處理程序以編輯非主地址。對於 LogisticsPostalAddress,以下是用於編輯網格控件中詳細信息的 X++ 代碼。

了解更多:如何使用 Apple Intelligence 的內置 ChatGPT 集成生成文本、圖像和見解

[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;

if(dirPartyLocation)
{
//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
if(!dirPartyLocation.IsPrimary)
{
//Edit the Postal Address details like City, State, Zip Code
logisticsPostalAddress_ds.allowEdit(true);
//Edit the name or description details in the Address
logisticsLocation_ds.allowEdit(true);

//Enable the purpose group
sender.control(sender.controlId(formControlStr(LogisticsPostalAddress,PurposeGroup))).enabled(true);
//IsPrimary toggle control disabled for non-Primary addresses
sender.control(sender.controlId(formControlStr(LogisticsPostalAddress,IsPrimary))).enabled(false);
}

}

}

}

物流電子地址碼:

[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 = element.design(0).controlName("DetailContactInfo");
deleteContactInfoButton = element.design(0).controlName("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
typeObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);
LocatorObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);
LocatorExtensionObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);
DescriptionObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);
CountryRegionCodeObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);
//IsPrimaryObject.allowEdit(!LogisticsElectronicAddress.IsPrimary);

// if contact information is primary
// disable the advanced button so users cannot edit details in that screen
advancedButton.enabled(!LogisticsElectronicAddress.IsPrimary);

// disable the delete button
deleteContactInfoButton.enabled(!LogisticsElectronicAddress.IsPrimary);
}
}
}

配置鍵:

LedgerBasic 是啟用 CustCustomerV3Entity 所需的配置密鑰。此功能在 Dynamics 365 for Finance and Operations 中啟用(默認)。

GitHub 鏈接:

代碼存儲庫已上傳到 github 上,以下是 Visual Studio 項目的鏈接。

筆記:
該項目駐留在 var 層。
https://github.com/nav21n/d365finops/tree/master/samples/CDSIntegration

模型文件也上傳到github上。導入模型並構建模型和項目。模型文件名為:D365DMOSamples.使用命令行導入模型文件。
模型文件名:D365DMOS樣品

用於導入模型文件的命令。在構建模型和項目之前必須執行以下步驟。在本例中,我選擇 C:Model_Backups 作為模型文件的源目錄。

圖 2 – 導入模型文件

參考:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/data-integration-cds