2017-06-19 50 views
3

我正在研究一種實用程序,該實用程序基於提供的目標解決方案創建回滾解決方案。 截至目前該實用程序工作正常,它讀取要部署在目標組織上的解決方案,並在目標組織中創建一個新的回滾解決方案,其中包含實體,Web資源,SDK步驟,安全角色,工作流等所有必需組件目標組織。 我已經使用SDK的AddSolutionComponentRequest類來實現這一點。將獨特的實體子組件添加到Dynamics CRM解決方案中

當實用程序檢測在溶液中的實體它只是增加了整個實體與所有像所有字段,視圖,表單等

CRM 2016引入的溶液的特徵分割元數據通過它我們可以特別添加那些已經改變的實體組件。

如何在我的實用程序中利用此功能,因爲我還沒有找到任何API方法允許我將特定實體組件添加到解決方案。

回答

0

看起來像CloneAsPatchRequest是要走的路。但它對父解決方案有依賴性。因此,您可能需要首先部署父解決方案,然後根據需要部署儘可能多的修補程序。

這些細節here

+0

你的回答解決了補丁的解決方案,而不是分割的解決方案。 –

3

對於實體類型的分段解決方案組件更多信息必須加入到與DoNotIncludeSubcomponents選項設置爲true解決方案。然後,可以將實體的不同部分逐個添加到解決方案中。

其中實體「賬戶」被添加到解決方案「測試」,只有屬性「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); 
相關問題