locked
Suspend a Workflow from a custom workflow activity RRS feed

  • Question

  • Hi There

    Can someone tell me how I can suspend a workflow from a called custom workflow activity, please.

     


    SQL Server and .Net developer using VB for the most part but a little C#
    Thursday, May 6, 2010 4:25 AM

Answers

  • I dont think this update would be reliable.

    A better approach would be to update a different entity/attribute from the custom activity. Add a step in the workflow to wait for some condition based on the entity/attribute that was updated.

     

    • Marked as answer by Jim Glass Jr Monday, May 10, 2010 3:09 PM
    Thursday, May 6, 2010 6:16 PM

All replies

  • Hi,

    I am not absolutely sure but you could try out this code

     

       IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
       IWorkflowContext workflowContext = contextService.Context;
       ICrmService crmService=workflowContext.CreateCrmService();
    
    
       TargetUpdateAsyncOperation updateAO = new TargetUpdateAsyncOperation();
       updateAO.AsyncOperation = new asyncoperation();
       updateAO.AsyncOperation.asyncoperationid = new Key();
       updateAO.AsyncOperation.asyncoperationid.Value = workflowContext.AsyncOperationId;
       updateAO.AsyncOperation.statecode=new AsyncOperationStateInfo();
       updateAO.AsyncOperation.statecode.Value = AsyncOperationState.Suspended; 
    
       UpdateRequest updateRequest = new UpdateRequest();
       updateRequest.Target = updateAO;
       UpdateResponse myRes = (UpdateResponse)crmService.Execute(updateRequest);  
    

     

    Regards,

    Nishant Rana

     


    http://nishantrana.wordpress.com
    • Proposed as answer by Mayank Pujara Thursday, May 6, 2010 8:19 AM
    Thursday, May 6, 2010 6:20 AM
  • I dont think this update would be reliable.

    A better approach would be to update a different entity/attribute from the custom activity. Add a step in the workflow to wait for some condition based on the entity/attribute that was updated.

     

    • Marked as answer by Jim Glass Jr Monday, May 10, 2010 3:09 PM
    Thursday, May 6, 2010 6:16 PM