locked
How to terminate workflow using Jquery ? RRS feed

  • Question

  • Hi ,

        I want to terminate workflow on button click, is there any way to terminate all version of workflow using Jquery ?

     


    Thanks and Regards Ajinkya Khandagale SharePoint Developer

    Friday, November 16, 2012 6:47 AM

All replies

  • Hi,

         Thanx swati for reply.but is it posible to terminate workflow using Jquery?is there any "StopWorkflow" opertion to terminate workflow like "StartWorkflow" in SPservices.

     $().SPServices({
         operation: "StartWorkflow",
         item: ItemURL,
         templateId: workflowGUID,
         workflowParameters: "<root />",
         completefunc: function() {
         }
       }); 

        


    Thanks and Regards Ajinkya Khandagale SharePoint Developer



    Friday, November 16, 2012 9:34 AM
  • Hi,

         Thanks swati for reply. i used following code in event receiver to terminate workflow

        

    oweb.AllowUnsafeUpdates = true;
    itemWorkflow.CreateHistoryEvent((int)SPWorkflowHistoryEventType.WorkflowCancelled, 0, oweb.CurrentUser, "Cancelled by the User", "Cancelled By Siva", null);
    oweb.AllowUnsafeUpdates = false;
    if (!itemWorkflow.IsLocked){
    foreach (SPWorkflowTask taskWorkflow in itemWorkflow.Tasks)
    {
    taskWorkflow["Status"] = "Canceled";
    oweb.AllowUnsafeUpdates = true;
    taskWorkflow.SystemUpdate();
    oweb.AllowUnsafeUpdates = false;
    }
    oweb.AllowUnsafeUpdates = true;
    SPWorkflowManager.CancelWorkflow(itemWorkflow);
    oweb.AllowUnsafeUpdates = false;

    Thanks and Regards Ajinkya Khandagale(SharePoint Developer)


    Friday, November 23, 2012 10:50 AM