TransWikia.com

workflowservices.js Error (get_context) when attempting to start 2013 Workflow via JavaScript

SharePoint Asked by syagla on November 8, 2021

I’m attempting to run the code provided in this thread:
Launch SharePoint 2013 Workflow w/Javascript

It’s a function which starts a SP 2013 Workflow given input parameters of Item ID and Subscription ID.

I keep getting an error on this line:

var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);

I keep getting a TypeError error:

this.get_context is not a function

Any ideas?

I’m attempting to run this from a web part. I see that sp.js, sp.core.js, and sp.runtime.js all appear to load by default.

The only one which I had to load with a script tag is sp.workflowservices.js.

My startWorkflow() function runs upon clicking a link, so I don’t think it’s a matter of code executing before scripts are properly loaded.

One Answer

Probably you pass SP.AppContextSite instead of SP.ClientContext when create SP.WorkflowServices.WorkflowServicesManager object.

Below is demonstrated how to properly instantiate WorkflowServicesManager object:

var clientContext = SP.ClientContext.get_current();
var workflowServicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(clientContext, clientContext.get_web());

Answered by Vadim Gremyachev on November 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP