none
0x800a138f - JavaScript runtime error: Unable to get property 'TaxonomySession' of undefined or null reference

    Question

  • I'm trying to access a TermSet in a SharePoint-hosted app.  I have this as a starter.

        var site = context.get_site();
        context.load(site);
        var taxSession = new SP.Taxonomy.TaxonomySession(context, site, false);
        var termStores = taxSession.get_termStores();
        var termSet = taxSession.getTermSetsByName("Department", 1033);
        alert("Term Stores: " + termStores.get_count());
        alert("Term Sets (Department): " + termSet.get_count);

    However, it errors out on the new TaxonomySession line with the error in the title.  I added a script tag in the default.aspx before the app.js tag to SP.Taxonomy.js.  It hasn't helped as I get the same error.

    Has anyone successfully manipulated a term in the JS CSOM?  How?

    Monday, August 27, 2012 8:17 PM

All replies

  • I've also added the permission request.  I thought that would be the issue, but that did not resolve it.
    Friday, August 31, 2012 8:26 PM
  • You're missing an ExecuteQueryAsync before your alerts.

    -AC [MVP SharePoint Server] http://www.andrewconnell.com/blog Critical Path Training, LLC SharePoint training for all audiences (developers, admins, end users, power users, web designers, etc) www.CriticalPathTraining.com

    Wednesday, September 05, 2012 1:48 AM
  • I get the same error as in the title of the post.  It errors before ever getting to the executeQueryAsync.  I even added context.load(...) for each of the following objects: site, taxSession, termStores, termSet.  

    I'm assuming it has to do with getting the SP.Taxonomy.js properly loaded.  What is the right way if that's the case?  I've tried using a ScriptLink (name="/_layouts/SP.Taxonomy.js" runat="server"), script (src="/_layouts/SP.Taxonomy.js"), and adding the script dynamically via jQuery using both the server-relative URL from script/ScriptLink as well as SPHostUrl (Query String) + "/_layouts/SP.Taxonomy.js."  None of these has worked.

    Wednesday, September 05, 2012 6:23 PM
  • Have you used Fiddler to see if it is loading? Some stuff isn't available in _layouts... to make 100% certain you have it, include the SP.Taxonomy.js in your project and load it that way.

    -AC [MVP SharePoint Server] http://www.andrewconnell.com/blog Critical Path Training, LLC SharePoint training for all audiences (developers, admins, end users, power users, web designers, etc) www.CriticalPathTraining.com

    Wednesday, September 05, 2012 6:34 PM
  • Didn't try Fiddler yet.  Just added into the app.  I can't imagine this will be the desired method, though.

    Now I'm getting errors in the get_termStores and getTermSetsByName.  

    get_termStores returns: 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'get_objectData

    getTermSetsByName returns: 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'get_context'

    getTermSetsByName is tested by setting as next statement after the new TaxonomySession.

    Wednesday, September 05, 2012 8:12 PM
  • Try adding jquery.1.7.1.js.  It solved mine.  

    Sathish | Mark the answers if it helps to solve your problem |

    Sunday, November 17, 2013 3:05 PM