Long story short I'm migrating SP2013 to SPO. Unfortunately the code is producing an error in the browser console that collListItem is undefined.

All I did was to replace the addresses where needed with the new ones including the imports of jQuery and other resources. The page itself has search functionality which is working fine and a list of letters to pick from (like a dictionary) to check manually for a given word. Upon selecting some of the letters nothing is displayed. After clicking the edit page button all the words are loaded.

I read that this is common issue and the solution was to use SP.SOD.executefunc. Much to my regret this doesn't seem to work. Last but not least this is just a small excerpt of the code. To keep it tidy I removed the html/css bits and some of the other functions where collListItem is also used but no problems there.

Any suggestions are welcome.

$("#btnSearch").click(function () {
    var txtsTerm = $("#txtSearch").val();
        var letter=$.trim(txtsTerm).substring(0,1);
        $('#'+ letter).addClass('aClick');
        //ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js"); 
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems);

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveautotextItems);
function retrieveautotextItems() {
        var siteUrl = 'https://contoso.com/sites/';
        var clientContext = new SP.ClientContext(siteUrl);
        // Get the list instance
        var oList = clientContext.get_web().get_lists().getByTitle('Term');

        var camlQuery = new SP.CamlQuery();

        var strQuery='';        
        strQuery="<View><Query><Where><And><Eq><FieldRef Name='IsActive'/><Value Type='Integer'>"+ "1" +"</Value></Eq><Neq><FieldRef Name='Term'/><Value Type='Text'>"+ "" +"</Value></Neq></And></Where></Query><RowLimit>1000</RowLimit></View>";
        this.collListItem = oList.getItems(camlQuery);


        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQueryAutoSucceeded), Function.createDelegate(this, this.onQueryAutoFailed));        


1 Answer 1



<script src="/sites/contoso/_layouts/15/SP.Runtime.js" type="text/javascript">
<script src="/sites/contoso/_layouts/15/SP.js" type="text/javascript">

to the html I was using for the CEWP fixed the problem for me

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.