Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

"The property or field has not been initialized" Error, when debbuging app

$
0
0

Hello,

I'm  following the instructions of a dev book but I get the following error message when debugging the app.

"The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."

The code:

var collListItems;

$(document).ready(function () {
    getConfigValues();
});

function getConfigValues() {
    var context = SP.ClientContext.get_current();
    var configList = context.get_web().get_lists().getByTitle('Configuration Values');
    var camlQuery = new SP.CamlQuery();
    collListItems = configList.getItems(camlQuery);
    context.load(collListItems);
    context.executeQueryAsync(onGetConfigValuesSuccess, onGetConfigValuesFail);
}

function onGetConfigValuesSuccess() {
    var OrgLogoUrl;
    var OrgName;
    var listItemEnumerator = collListItems.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        var current = oListItem.get_item('Title');
        switch (current) {
            case 'OrganizationName':
                OrgName = oListItem.get_item('Value');
                break;
            case 'OrganizationLogoUrl':
                OrgLogoUrl = oListItem.get_item('Value');
                break;
        };
    }

    if (OrgName && OrgName.length > 0) {
        $('#DeltaPlaceHolderPageTitleInTitleArea').html(OrgName);
        $('.ms-siteicon-img').attr('title', OrgName);
    }

    if (OrgLogoUrl && OrgLogoUrl.length > 0)
        $('.ms-siteicon-img').attr('src', OrgLogoUrl);
    else
        $('.ms-siteicon-img').attr('src', '../Images/AppLogo.png');
}

function onGetConfigValuesFail(sender, args) {
    alert('Failed to get the Configuration Values. Error:' + args.get_message());
}

What it have to do is to replace the Title and Site logo, using the "Title" and "Value" fields of the "Configuration Values" list.

My dev environment: SharePoint online, Azure, VS2013 Ultimate (trial)

I've tried to reach the author of the book but it's being 4 days and no response, maybe somebody here can help me.

Thanks in advance.

Jimmy


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>