locked
CRM 2013 - Convert Async workflow to Synchronous RRS feed

  • Question

  • Hi,

    I already have a async workflow in place in CRM but I would like to convert the workflow to synchronous workflow and set ‘Execute’ as “The user who made changes to the record” in the synchronous workflow programmatically. I am able to find the required workflow and deactivate it. How do I set the workflow's mode property to WorkflowMode.Realtime?

    //Deactivate the workflow
                        var deactivateRequest = new SetStateRequest
                        {
                        EntityMoniker = new EntityReference (Workflow.EntityLogicalName, ent.Id),
                        State = new OptionSetValue((int)WorkflowState.Draft),
                        Status = new OptionSetValue(1)
                        };
                        orgService.Execute(deactivateRequest);
                        
                        //Convert workflow to Synchronous workflow
                        UpdateRequest updateWorkflowType = new UpdateRequest()
                        {
                            //How to set Mode property to WorkflowMode.Realtime?
                        };
                        orgService.Execute(updateWorkflowType);

    Thanks,

    Anna'



    • Edited by Anna' Wednesday, January 28, 2015 9:50 PM
    Wednesday, January 28, 2015 9:47 PM

Answers

  • Hello,

    Try to use following code:

    Entity workflow = new Entity("workflow")
    {
    	Id = ent.Id
    };
    workflow["mode"] = new OptionSet(1);
    
    orgService.Update(workflow);



    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog


    Thursday, January 29, 2015 10:23 AM
    Moderator

All replies

  • Hello,

    Try to use following code:

    Entity workflow = new Entity("workflow")
    {
    	Id = ent.Id
    };
    workflow["mode"] = new OptionSet(1);
    
    orgService.Update(workflow);



    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog


    Thursday, January 29, 2015 10:23 AM
    Moderator
  • Thank you!
    Thursday, January 29, 2015 5:48 PM