2

I cant run my code. I get this error message:

0x800a139e - Runtime Errors in JavaScript : The property or field has not been initialized . There has been no request or has not been performed. It might need to be requested specifically.

I created an app (custom list) on developer site. In that list I created 3 columns (Title, Status and Responsible). And I also added some items to fetch them with my code. It displays column titles but when I want to fetch Resposible column it give me the error. In appManifest I added Web to Full Control.

'use strict';

var context = new SP.ClientContext.get_current();
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var parentContext = new SP.AppContextSite(context, hostweburl);
var parentWeb = parentContext.get_web();
var listitemCollection = parentWeb.get_lists().getByTitle("CaseList").getItems("");


$(document).ready(function () {

    context.load(listitemCollection);
    context.executeQueryAsync(onSuccess, onFail);
});

function onSuccess() {

    var itemString1 = "";
    var itemString2 = "";
    var itemString3 = "";

    var listEnumerator = listitemCollection.getEnumerator();
    var currentItem;

    while (listEnumerator.moveNext()) {
        currentItem = listEnumerator.get_current();
        if (currentItem.get_item('Status') == "New") {
            itemString1 += "<br/>" + currentItem.get_item('Title') + " " + currentItem.get_item('Responsible');
        }
        else if (currentItem.get_item('Status') == "Started") {
            currentItem = listEnumerator.get_current();
            itemString2 += "<br/>" + currentItem.get_item('Title') + " " + currentItem.get_item('Responsible');
        }
        else if (currentItem.get_item('Status') == "Finished") {
            currentItem = listEnumerator.get_current();
            itemString3 += "<br/>" + currentItem.get_item('Title') + " " + currentItem.get_item('Responsible');
        }
    }

    $("#Show1").html(itemString1);
    $("#Show2").html(itemString2);
    $("#Show3").html(itemString3);
}

function onFail(sender, args) {
    alert("Error:" + args.get_message());
}

function getQueryStringParameter(paramToRetrieve) {
    var params = document.URL.split("?")[1].split("&");
    var strParams = "";
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split("=");
        if (singleParam[0] == paramToRetrieve)
            return singleParam[1];
    }
}
2

You can request for additional fields using

 context.load(listitemCollection, 'Include(Responsible,Status)');
  • I tried with that. But now I get a new error. "Error: Coloumn Responsible is not there. It may has been deleted by another user." Which I find it very strange. When I go to my developer site I can see my list with that column name. – Sunreuz May 31 '15 at 10:24
  • At least the previous error is gone. – Sunreuz May 31 '15 at 11:05
  • Make sure you are using the correct internal name and not display name – Amal Hashim May 31 '15 at 11:14
  • Okey I can try that. But when I add a column in the list how can I see the internal name? My list is in developer site. The column names are "Ansvarig", "Totalsumma" and "Responsible". – Sunreuz May 31 '15 at 11:18
  • You can open the fields from List Settings and check URL query string Field= – Amal Hashim May 31 '15 at 11:19
0

Maybe for some items that column value is null or empty.

Check this condition each time you are retrieving some column values:

item.get_item('internalColumnName')!= null

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.