I'm using the following code to start a workflow from the javascript on an edit form:

var context = SP.ClientContext.get_current();
var web = context.get_web();
var wfServiceManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);
var subscription = wfServiceManager.getWorkflowSubscriptionService().getSubscription(_workflowId);


... and then on with the async query

The problem is with the wfServiceManger.getWorkflowSubscriptionService() part. Sometimes the wfServiceManager is created with a context object in it and other times it isn't. I get the following error when there is no contextobject in the workflowServicesManager:

Uncaught TypeError: this.get_context is not a function
    at SP.WorkflowServices.WorkflowServicesManager.getWorkflowSubscriptionService

I can't see any reason why one time it would return a properly formmed WorkflowServicesManager and other times not.

I'm finding some other places where people get the this.get_context() is not a function. Those seem to revolve around loading of required js files. I'm loading:

  • core.js
  • sp.js
  • sp.runtime.js
  • sp.ui.dialog.js
  • sp.workflowservices.js

And they all seem to be loaded and available (as best I can tell from the debugger).

Any ideas?

1 Answer 1


It looks like we had three different problems.

In some of our javascript code we had "Use strict"; not sure, but that seems to have cause some problems somewhere in the one of the sharepoint javascript files. So we removed it.

We had multiple copies of sp.js loading with SP.SOD.loadMultiple() in a couple of different js files. We removed that and changed it to SP.SOD.executeOrDelayUntilScriptLoaded(init, 'SP.js').

But removing the loadMultiple meant that sp.workflows.js was loading before sp.js, only in IE and not Chrome. So we moved the load of that into the init function called when sp.js loads.

Your Answer

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

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