![](/img/trans.png)
[英]Register a Plugin on a Entity when a Solution is imported in Microsoft Dynamics 365 CRM
[英]Add distinctive entity sub components to a Dynamics CRM solution
我正在開發一個實用程序,我將根據提供的目標解決方案創建回滾解決方案。 截至目前,該實用程序工作正常,它讀取要部署在目標組織上的解決方案,並在目標組織上創建一個新的回滾解決方案,其中包含來自目標的實體,Web資源,SDK步驟,安全角色,工作流等所有必需組件有機 我使用SDK的AddSolutionComponentRequest
類來實現這一點。
當實用程序在解決方案中檢測到實體時,它只是添加整個實體以及所有元數據,如所有字段,視圖,表單等。
CRM 2016引入了解決方案細分的功能,通過它我們可以專門添加已更改的實體組件。
如何在我的實用程序中利用此功能,因為我還沒有找到允許我向解決方案添加特定實體組件的任何API方法。
對於分段解決方案,必須將DoNotIncludeSubcomponents
類型的組件添加到解決方案中,並將DoNotIncludeSubcomponents
選項設置為true
。 然后,可以將實體的獨特部分逐一添加到解決方案中。
將實體“account”添加到解決方案“Test”且僅包含屬性“accountnumber”的示例:
private static EntityMetadata RetrieveEntity(string entityName, IOrganizationService service)
{
var request = new RetrieveEntityRequest
{
LogicalName = entityName,
EntityFilters = EntityFilters.All,
RetrieveAsIfPublished = true
};
return ((RetrieveEntityResponse)service.Execute(request)).EntityMetadata;
}
private static void AddEntityComponent(Guid componentId, int componentType, string solutionName, IOrganizationService service)
{
var request = new AddSolutionComponentRequest
{
AddRequiredComponents = false,
ComponentId = componentId,
ComponentType = componentType,
DoNotIncludeSubcomponents = true,
SolutionUniqueName = solutionName
};
service.Execute(request);
}
IOrganizationService service = factory.CreateOrganizationService(null);
EntityMetadata entity = RetrieveEntity("account", service);
AddEntityComponent(entity.MetadataId.Value, 1, "Test", service);
AddEntityComponent(entity.Attributes.First(a => a.LogicalName == "accountnumber").MetadataId.Value, 2, "Test", service);
看起來像CloneAsPatchRequest是要走的路。 但它依賴於父解決方案。 因此,您可能需要先部署父解決方案,然后根據需要部署盡可能多的補丁。
有關這些詳細信息,請點擊此處
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.