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);
context.load(subscription);
... 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?