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
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');
| improve this answer | |
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

| improve this answer | |
  • the bug was in chrome, I didn't even try in IE. – dinnouti Jan 6 '17 at 22:43

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.