I get the error :

Object doesn't support property or method 'set_formDigestHandlingEnabled'

when I try to get the current SPContext object from javascript code in an Office 365 site.

I am using a script editor web part and getting the context to do further operations

var cntxt;
cntxt = SP.ClientContext.get_current()

Has anyone faced this before?

  • 2
    Have you tried cntxt = new SP.ClientContext(currentUrl);? – wjervis Jul 30 '14 at 12:43
  • I have tried that. Doesn't work !! – Vipul Kelkar Jul 30 '14 at 20:19
  • Are you making the call from an app or a regular site collection on your O365 host? – John-M Jul 31 '14 at 0:55
  • Not an app. I have just placed a script editor web part on my page in an Office 365 site collection. If I try to get the "SP" and "SP.ClientContext" objects in the IE developer toolbar console, the objects are returned.. It is just the "get_current()" method that is throwing the error !! – Vipul Kelkar Jul 31 '14 at 9:06
  • Try removing all other custom scripts from the page, and then calling SP.ClientContext.get_current() in the console; does this happen on just this page, or others, just this site collection, or others? – John-M Jul 31 '14 at 10:30

Based on comments to the original question, the way in which the scripts are loaded on your page must be preventing SharePoint from initializing all of the standard JavaScript items on the page. Add your custom scripts one by one, and remember that you may need to use jQuery.ready, SP.SOD.ExecuteOrDelayUntilScriptLoaded(<yourscript>, "SP.js") // or sp.ui, or sp.core, or something else, but usually SP.js is sufficient, or some other similar technique to make sure SharePoint has initialized its environment before you load your custom script.


I had the same error message in a html without SharePoint Server rendering. For me I mixed up the load sequence of the sp.runtime.js and sp.js. You have to load the sp.runtime.js before the sp.js

  <script src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
  <script src="/_layouts/15/sp.runtime.js"></script>
  <script src="/_layouts/15/sp.js"></script>
  • this helped..... – Gaurravs Jun 7 '18 at 15:52

Using 'new' is definitely required, as suggested by wjervis: var context = new SP.ClientContext(currentUrl);

  • Adding 'new' worked for me. – Asad Refai Jun 9 '16 at 9:23

You need to use ExecuteOrDelayUntilScriptLoaded function :

ExecuteOrDelayUntilScriptLoaded(internalOpenDialog, "SP.JS");

function internalOpenDialog(){

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.