0

Getting the following error when running my script:

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

My code :

NBSFeedbackEditInbox.FeedbackRemove = (function () {

    var collListItems;
    removemessage = function (getid) {

        NBSFeedbackEditInbox.siteURL = _spPageContextInfo.siteAbsoluteUrl + '/Community/News-and-feedback/Feedback';
        var clientContext = new SP.ClientContext(NBSFeedbackEditInbox.siteURL);
        var oList = clientContext.get_web().get_lists().getByTitle('Feedback Items');

        var querystring = jQuery('#createdby').text();

        for (var i = 0; i < getid.length; i++) {


            getid[i] = getid[i].substring(getid[i].lastIndexOf('#') + 1);
            getid[i] = Math.round(getid[i]);

        }

        if (getid.length != 0) {
            var query = SP.CamlQuery.createAllItemsQuery();
            query.set_viewXml("<View Scope='RecursiveAll'><Query><Where><Contains><FieldRef Name='Author'/><Value Type='Text'>" + querystring + "</Value></Contains></Where></Query></View>");
            collListItems = oList.getItems(query);


            clientContext.load(collListItems, 'Include(Title, ID,IsDeleted,RequireFeedback)');

            clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        }

    }
    onQuerySucceeded = function () {
        var itemTitle = [];
        var sentnumber = 0;
        var inboxnumber = 0;

        var listItemEnumeratorlistFeedback = collListItems.getEnumerator();
        while (listItemEnumeratorlistFeedback.moveNext()) {

            feedbackListItem = listItemEnumeratorlistFeedback.get_current();

            if (feedbackListItem.get_item('IsDeleted') == 'Sent' || feedbackListItem.get_item('RequireFeedback') == false || feedbackListItem.get_item('IsDeleted') == 'Both') {
                jQuery("div[title='" + (feedbackListItem.get_item('Title')) + "sent']").parent().parent().parent().parent().css('display', 'none');

                var sentlength = jQuery('.nbsallmessagecountsent').filter(function () { return $(this).css("display") != "none" }).length;


                jQuery("#nbsmessagesentcount").text('Showing ' + sentlength + ' of ' + sentlength + ' conversations');
                if (sentlength <= 0) {
                    jQuery('#sentcounters').addClass('nbsmessageremoval');
                } else {
                    jQuery('#sentcounters').removeClass('nbsmessageremoval');
                }



            }

            if (feedbackListItem.get_item('IsDeleted') == 'Inbox' || feedbackListItem.get_item('IsDeleted') == 'Both') {

                jQuery("div[title='" + (feedbackListItem.get_item('Title')) + "inbox']").parent().parent().parent().parent().css('display', 'none');
                var inboxlength = jQuery('.allmessagecount').filter(function () { return $(this).css("display") != "none" }).length;
                jQuery("#nbsmessageinboxcount").text('Showing ' + inboxlength + ' of ' + inboxlength + ' conversations');

                if (inboxlength == 0) {
                    jQuery('#nbsnewmessages').text('');
                } else {
                    jQuery('#nbsnewmessages').text('(' + inboxlength + ')');
                }
                if (inboxlength <= 0) {
                    jQuery('#nbsdeletemessage').addClass('nbsmessageremoval');
                } else {
                    jQuery('#nbsdeletemessage').removeClass('nbsmessageremoval');
                }

            }
        }

    }

    onQueryFailed = function (sender, args) {

    }

    return {
        removemessage: removemessage
    }

})()

And I call it using SP.SOD.executeOrDelayUntilScriptLoaded("sp.js","SP.ClientContext",someSimpleWrapper);

1
  • 1
    You are using executeOrDelayUntilScriptLoaded wrong there, thats the syntax for SP.SOD.execute() . This is the right syntax: SP.SOD.executeOrDelayUntilScriptLoaded(func, depScriptFileName); msdn.microsoft.com/en-us/library/office/… Commented Nov 12, 2014 at 20:30

1 Answer 1

0

Change var query = SP.CamlQuery.createAllItemsQuery(); to var query = new SP.CamlQuery();

3
  • nope doesn't work
    – Asad
    Commented Nov 12, 2014 at 15:04
  • Try removing <View Scope='RecursiveAll'> to <View>. Please confirm the item you are searching actually returns results. Commented Nov 12, 2014 at 15:25
  • it was working fine until I added the SP.SOD.executeOrDelayUntilScriptLoaded("sp.js","SP.ClientContext",someSimpleWrapper); to sort out another bug
    – Asad
    Commented Nov 12, 2014 at 15:30

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.