I have a SharePoint with several calendars named for their store number, I also have a list named Store Addresses which has the store numbers and their addresses.

I am trying to display the address on the top of the calendar page along with the page name (e.g., Store 500 - 111 Main St). I figured out how to display the page name, but need help pulling in and displaying the address.

I am using JavaScript to achieve this.

Edit: With help from a coworker we created the following code. But when we run it, it comes up with the error alert.

<script language="JavaScript">
var storeNumber = document.getElementsByTagName("title")[0].innerHTML;
var fieldValue = "";
storeNumber = storeNumber.split("-")[0];

SP.SOD.executeFunc('sp.js', 'SP.ClientContext',   function () {


function loadSharepointList() {

            var context = SP.ClientContext.get_current();

var list = context.get_web().get_lists().getByTitle('storeAddresses');

            var caml = new SP.CamlQuery();
     '<View><Query><Where><Eq>' +                                                                      
     '<FieldRef Name=\'Title\'/><Value>'+storeNumber+'</Value>' +

            var listItems = list.getItems(caml);
            context.load(listItems , 'Include(address)');

            Function.createDelegate(this, function() {
                           fieldValue = listItems.get_item('address');

            Function.createDelegate(this, function() {
                                           alert('Error fetching data from Sharepoint!');       

document.getElementById("testDiv").innerHTML = (storeNumber + "-" +  fieldValue);}

1 Answer 1


You could use SharePoint rest api to get the list items in Store Addresses, then display the page name and address by jQuery.

Sample rest api demo from this thread.

function retriveListItem()  

        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('companyInfo')/items?$select=Company,Industry",  
        type: type,  
        data: data,  
            "Accept": "application/json;odata=verbose",  
            "Content-Type": "application/json;odata=verbose",  
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
            "IF-MATCH": "*",  
            "X-HTTP-Method": null  
        cache: false,  
        success: function(data)   
            for (var i = 0; i < data.d.results.length; i++)   
                var item = data.d.results[i];  
                $("#ResultDiv").append(item.Company + "\t" + item.Industry + "<br/>");  
        error: function(data)  

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.