This project is read-only.
2

Closed

Unable to get property 'create' of undefined or null reference

description

Hi,
I am using this tool for the first time and I am getting following error:

Unable to get property 'create' of undefined or null reference

Here is my jquery code:
var camlBuilder = new CamlBuilder();
            var Query = camlBuilder.Where()
                .TextField("Evidence").EqualTo("test")
                .Or()
                .TextField("LinkTitle").BeginsWith("1.01.")
                .ToString();
Closed Sep 21, 2014 at 1:32 AM by omlin
Use camljs.spdefs.js if you're running SP2007 or standalone; or if you're running SP2010+, ensure that sp.runtime.js is loaded before your script is executed.

comments

awmay wrote Aug 21, 2014 at 4:59 PM

I'm getting the same thing using the example from the project description:
var camlQuery = new CamlBuilder().Where().Any(
    CamlBuilder.Expression().TextField("Email").EqualTo("support@google.com"), 
    CamlBuilder.Expression().TextField("Email").EqualTo("plus@google.com"), 
    CamlBuilder.Expression().TextField("Title").BeginsWith("[Google]"), 
    CamlBuilder.Expression().TextField("Content").Contains("Google")
).ToString();
Chrome console error:
Uncaught TypeError: Cannot read property 'create' of undefined camljs.js:627
Builder.Finalize camljs.js:627
QueryToken.ToString camljs.js:134
(anonymous function)
Am I missing something?

omlin wrote Aug 25, 2014 at 1:59 AM

CamlJs has some dependencies on available by default in SharePoint 2010/2013 classes Sys.StringBuilder and SP.XmlWriter. That is what causing the error: camljs tries to execute Sys.StringBuilder.create method.

Recently I had compiled a separate file for those who want to use camljs in SP2007 or outside of SharePoint portals.

You can find it here: https://camljs.codeplex.com/SourceControl/latest#CamlJs/camljs.spdeps.js

Example of usage is in folder "sp2007orStandalone" next to this file.

If you are working in SP2010 or SP2013, then you probably don't have the files deployed to the page or don't have them loaded. Please ensure that sp.js and sp.runtime.js are loaded before calling camljs.