Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

Problem with import solution to CRM programmatically

$
0
0

Hi all,

I have problem with import solution to CRM 2011. You can see my source code below:

byte[] fileBytes = File.ReadAllBytes(solutionPath);

ImportSolutionRequest importSolutionRequest = new ImportSolutionRequest();
importSolutionRequest.CustomizationFile = fileBytes;
ImportSolutionResponse importSolutionResponse = (ImportSolutionResponse)service.Execute(importSolutionRequest);

PublishAllXmlRequest publishRequest = new PublishAllXmlRequest();
service.Execute(publishRequest);

FilterExpression workflowFilter = new FilterExpression();
workflowFilter.AddCondition("name", ConditionOperator.Equal, "My workflow name");

EntityCollection workflows = CRMServiceControl.RetrieveMultiple("workflow", workflowFilter, new ColumnSet(true), service);

if (workflows.Entities.Count > 0)
{
    foreach (Entity workflow in workflows.Entities)
    {
        SetStateRequest activateRequest = new SetStateRequest
        {
            EntityMoniker = new EntityReference("workflow", workflow.Id),
            State = new OptionSetValue(1),
            Status = new OptionSetValue(2)
        };
        service.Execute(activateRequest);
    }
}

Code with no problems imports solution to CRM 2011 but when I want to activate workflow I have found by FilterExpression so then I got this error message:Only workflow definition or draft workflow template can be published.

Now, I do not know if that problem is in CRM solution or I made same mistake in my code.

Thanks for help.

Jan Holinka





Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>