Dynamics 365导入解决方案报错:无法添加类型29的根组件
我正在Microsoft Dynamics 365(客户服务)环境中从零创建工作流,目标是通过解决方案导入,在目标环境生成该工作流(目标环境原本没有这个GUID的工作流)。我已经在customizations.xml和solution.xml中完成定义,但导入时遇到报错:
Cannot add a Root Component c73e3d27-f75e-ef11-bfe3-000d3ad4b474 of type 29 because it is not in the target system.
之前尝试在solution.xml中用schemaName引用工作流(类比WebResource的成功引用方式)但没效果。关联的XAML文件是之前通过门户创建、导出后从环境移除的,本身没问题——当目标环境存在该ID的工作流时,解决方案能正常导入。使用的API版本是9.1。
提供的代码片段
solution.xml代码片段
... <RootComponents> <RootComponent type="1" schemaName="incident" behavior="1" /> <RootComponent type="61" schemaName="py15_caseTypeFilterLib" behavior="0" /> <RootComponent type="29" id="{c73e3d27-f75e-ef11-bfe3-000d3ad4b474}" behavior="2" /> <!--RootComponent type="29" schemaName="py15_caseTypeWorkflow" behavior="2" /--> </RootComponents> <MissingDependencies />
customizations.xml代码片段
... <Workflows> <Workflow WorkflowId="{c73e3d27-f75e-ef11-bfe3-000d3ad4b474}" Name="py15_caseTypeWorkflow"> <XamlFileName>/Workflows/ReplaceCaseType.xaml</XamlFileName> <Name>py15_caseTypeWorkflow</Name> <Type>1</Type> <Subprocess>0</Subprocess> <Category>0</Category> <Mode>0</Mode> <Scope>4</Scope> <OnDemand>0</OnDemand> <TriggerOnUpdateAttributeList>casetypecode</TriggerOnUpdateAttributeList> <TriggerOnCreate>1</TriggerOnCreate> <TriggerOnDelete>0</TriggerOnDelete> <AsyncAutodelete>1</AsyncAutodelete> <SyncWorkflowLogOnFailure>0</SyncWorkflowLogOnFailure> <StateCode>1</StateCode> <StatusCode>2</StatusCode> <RunAs>1</RunAs> <IsTransacted>1</IsTransacted> <IntroducedVersion>1.0.0.0</IntroducedVersion> <IsCustomizable>1</IsCustomizable> <BusinessProcessType>0</BusinessProcessType> <IsCustomProcessingStepAllowedForOtherPublishers>1</IsCustomProcessingStepAllowedForOtherPublishers> <PrimaryEntity>Incident</PrimaryEntity> <LocalizedNames> <LocalizedName languagecode="1033" description="Replace Case Type"/> </LocalizedNames> </Workflow> </Workflows> </ImportExportXml>
解决方案尝试方向
修正RootComponent的behavior属性
当前使用的behavior="2"(覆盖模式)要求目标环境已存在该组件,但你的场景是全新创建,需改为behavior="0"(创建模式):<RootComponent type="29" id="{c73e3d27-f75e-ef11-bfe3-000d3ad4b474}" behavior="0" />改用schemaName引用工作流
取消注释之前的schemaName引用行,删除ID引用行。对于全新组件,用schemaName更可靠,避免ID识别问题:<!--<RootComponent type="29" id="{c73e3d27-f75e-ef11-bfe3-000d3ad4b474}" behavior="2" />--> <RootComponent type="29" schemaName="py15_caseTypeWorkflow" behavior="0" />验证XAML文件的存在与路径
检查解决方案压缩包内是否存在/Workflows/ReplaceCaseType.xaml文件,路径、文件名(含大小写)需与customizations.xml中的定义完全一致。补充工作流必填属性
对比正常导出的工作流XML,确认customizations.xml中是否缺失SolutionId、PublisherId等必要属性,补充后重新打包。检查解决方案打包完整性
确保压缩包包含所有必要文件:customizations.xml、solution.xml、XAML文件,且目录结构正确。
内容的提问来源于stack exchange,提问作者Tatiana Goretskaya

