Sharepoint - Uncaught TypeError: Cannot read property 'get_current' of undefined
Since you are using SP.ClientContext
in CSR, make sure the SharePoint script file 'sp.js' is loaded before your rendering code runs:
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){
//Your code goes here...
});
fixed with this
$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(CustomAction, "sp.js"); });
function CustomAction()
{
//Your Code
}
This works for me when I am using WorkflowServices. It should work in your case as well:
ExecuteOrDelayUntilScriptLoaded(function () {
ExecuteOrDelayUntilScriptLoaded(function () {
SP.SOD.registerSod('SP.ClientContext', SP.Utilities.Utility.getLayoutsPageUrl('sp.js'));
SP.SOD.registerSod('SP.WorkflowServices.WorkflowServicesManager', SP.Utilities.Utility.getLayoutsPageUrl('SP.WorkflowServices.js'));
SP.SOD.loadMultiple(['SP.ClientContext', 'SP.WorkflowServices.WorkflowServicesManager'], function () {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var servicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);
var instanceService = servicesManager.getWorkflowInstanceService();
});
}, "sp.js");
}, "sp.runtime.js");