3

I am running a simple CamlJs, it works from Chrome Console and from the Chrome Extension. However when I try from a Content Editor Webpart (Sharepoint Online / O365) it gives me an error.

<script src="/sites/intranet/Style%20Library/CI/scripts/document_library/camljs.js"></script>
<script type="text/javascript">       
 var str = new CamlBuilder()
            .Where()
            .LookupMultiField("Tag")
            .IncludesSuchItemThat()
            .ValueAsText()
            .In(['a', 'b', 'authorization form'])
            .ToString();
console.log(str);
</script>

This is the error:

camljs.js:948 Uncaught TypeError: Cannot read property 'create' of undefined
    at Builder.Finalize (camljs.js:948)
    at QueryToken.ToString (camljs.js:304)
    at doclib.aspx:1123

2 Answers 2

3

Try to put your code inside SP.SOD.executeOrDelayUntilScriptLoaded block.
camljs uses some functions which are not availiable on document load.

SP.SOD.executeOrDelayUntilScriptLoaded(function(){
var str = new CamlBuilder()
            .Where()
            .LookupMultiField("Tag")
            .IncludesSuchItemThat()
            .ValueAsText()
            .In(['a', 'b', 'authorization form'])
            .ToString();
console.log(str);  
}, 'sp.js');
0
0

In my experience that usually has to do with IE versions that don't render later jquery functions: try to load https://github.com/es-shims/es5-shim

1
  • the bug was in chrome, I didn't even try in IE.
    – dinnouti
    Commented Jan 6, 2017 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.