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.

  • Are you loading the sp.js, sp.core.js, and sp.runtime.js before you are calling get_context() function? Maybe you need to use: SP.SOD.executeOrDelayUntilScriptLoaded – SOURAV MUKHERJEE Jul 21 '20 at 15:20

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());
  • Hmm...I checked over my code and that's exactly what I'm doing. Thank you for the advice though. – syagla Jun 23 '14 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.