Import Workflow using MetadataService or CrmService

0

I've been able to import entities from an XML file into my Dynamics instance using ImportXmlRequest as follows:

// Create the import request

ImportXmlRequest importRequest = new ImportXmlRequest {
ParameterXml =@"<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);

That works fine.

I also need to import workflows from an XML file into my Dynamics instance. I tried using the same approach but I kept getting the following error: '0x80040216 unrecognized format'.

I was able to get it working by adding the XML file containg the workflows to a ZIP file and then importing the ZIP file using ImportCompressedAllXmlRequest.

Is ImportCompressedAllXmlRequest the only way to import workflows or am I missing something obvious with the ImportXmlRequest?

Thanks,

David

dynamics-crm
dynamics-crm-4
asked on Stack Overflow Jan 24, 2011 by dlarkin77 • edited Jun 20, 2020 by Community

1 Answer

0

I actually had a stupid bug in my code. I was able to use ImportXmlRequest to import workflows by setting the ImportXmlRequest's ParameterXml as follows:

<importexportxml>
    <entities/>
    <nodes/>
    <securityroles/>
    <settings/>
    <workflows>
        <workflow>{97db1a25-af1c-4534-9805-c867d6585c8a}</workflow>
    </workflows>
</importexportxml>"
answered on Stack Overflow Jan 25, 2011 by dlarkin77

User contributions licensed under CC BY-SA 3.0