how to kickoff sharepoint 2013 designer list workflow with workflow parameters(need actual working example) via CSOM JS

how to kickoff sharepoint 2013 designer list workflow with workflow parameters(need actual working example) via CSOM JS

.

I tried many samples but on async call it gives subscription

August 27th, 2015 9:35pm

Hi Amit,

As your description, you want to kick off SharePoint 2013 list workflows via JavaScript Client Object Model.

There are some aritcles about managing SharePoint workflows via JavaScript Client Object Model, you can refer to them:

Managing SharePoint 2013 Workflows with CSOM

Start SharePoint Workflows with JavaScript Client Object Model

To start a 2010 workflow, you can use InteropService:

Using the SharePoint 2013 Workflow Interop Service in CSOM

Best Regards,

Wendy

Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 1:54am

Thanks Wendy. I already visited these but these are c# based and for sp2010. I need a working example for sharepoint 2013 which is really working in any working live site collection for sp2013 csom kickoff via Javascript.
August 31st, 2015 12:53pm

Hi Amit,

The article is for SharePoint 2013 workflow, please take a look at:

http://www.vrdmn.com/2014/05/managing-sharepoint-2013-workflows-with.html

Best Regards,

Wendy

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 9:04am

Thats correct Wendy but its c# based. I need working sample for javascript based csom. Thanks for your support on this.
September 1st, 2015 8:44pm

Hi Amit,

You can try to use the following JavaScript Client Object Model code to start a workflow:

//dialog element to show during processing
var dlg = null;      

//Subscription id - Workflow subscription id
//list item id for which to start workflow. If site workflow, then send null for itemId
function StartWorkflow(subscriptionId, itemId) {
   showInProgressDialog();
   var ctx = SP.ClientContext.get_current();
   var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx, ctx.get_web());
   var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);
   ctx.load(subscription, 'PropertyDefinitions');
   ctx.executeQueryAsync(
       function (sender, args) {
           var params= new Object();
           //Find initiation data to be passed to workflow.
           var formData = subscription.get_propertyDefinitions()["FormData"];
           if (formData != null && formData != 'undefined' && formData != "") {
               var assocParams = formData.split(";#");
               for (var i = 0; i < assocParams.length; i++) {
                   params[assocParams[i]] = subscription.get_propertyDefinitions()[assocParams[i]];
               }
           }
           if (itemId) {
               wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, params);
           }
           else {
               wfManager.getWorkflowInstanceService().startWorkflow(subscription, params);
           }
           ctx.executeQueryAsync(
               function (sender, args) {
                   closeInProgressDialog();
               },
               function (sender, args) {
                   closeInProgressDialog();
                   alert('Failed to run workflow');
               }
           );
       },
       function (sender, args) {
           closeInProgressDialog();
           alert('Failed to run workflow');
       }
   );
 }

function closeInProgressDialog() {
   if (dlg != null) {
       dlg.close();
   }
}
 

function showInProgressDialog() {
   if (dlg == null) {
       dlg = SP.UI.ModalDialog.showWaitScreenWithNoClose("Please wait...", "Waiting for workflow...", null, null);
   }
}

More information:

http://ranaictiu-technicalblog.blogspot.com/2013/06/sharepoint-2013-start-workflow-with.html

Some useful articles for your reference:

http://www.codeproject.com/Articles/607127/Using-SharePoint-Workflow-Services-JS-API

http://www.codeproject.com/Articles/782859/Working-with-Workflow-Service-in-JavaScript-JSOM-i

Best Regards,

Wendy

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 3:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics