2011-01-24 27 views
0

我已经能够从导入XML文件实体到使用ImportXmlRequest我的动态情况如下:导入工作流使用MetadataService或CrmService

// Create the import request

ImportXmlRequest importRequest = new ImportXmlRequest {
ParameterXml [email protected]"<entities><entity>MyFirstEntity<entity>MySecondEntity</entities><nodes/><securityroles/><settings/><workflows/></importexportxml>" };

string customizationPath = "entityCustomizations.xml";

// Pass the stream of customization XML to the import request using

(StreamReader sr = new StreamReader(customizationPath)) {
string customizationXml = sr.ReadToEnd();
importRequest.CustomizationXml = customizationXml; }

// Import the customizations myCrmService.Execute(importRequest);

这工作正常。

我还需要从XML文件导入工作流到我的Dynamics实例。我尝试使用相同的方法,但我不断收到以下错误:'0x80040216无法识别的格式'。

我可以通过将包含工作流的XML文件添加到ZIP文件,然后使用ImportCompressedAllXmlRequest导入ZIP文件来获得它。

是ImportCompressedAllXmlRequest导入工作流程的唯一方法,还是我缺少显式的ImportXmlRequest?

感谢,

大卫

回答

0

其实我在我的代码有一个愚蠢的错误。通过设置ImportXmlRequest的ParameterXml,我可以使用ImportXmlRequest导入工作流程,如下所示:

<importexportxml> 
    <entities/> 
    <nodes/> 
    <securityroles/> 
    <settings/> 
    <workflows> 
     <workflow>{97db1a25-af1c-4534-9805-c867d6585c8a}</workflow> 
    </workflows> 
</importexportxml>"