1

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.

1
  • 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 Commented Jul 21, 2020 at 15:20

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.