3

I have added a new "Promoted Link" list which comes with some built-in fields such as :

  • Title
  • Link Location

I am trying to query this list using REST end point, and dynamically build my view , as follow:-

$.ajax({
     url: "/_api/web/lists/getbytitle('Useful Links')/items?$select=Title,LinkLocation&$orderby=Title asc",
     method: "GET",   
     headers: { "Accept": "application/json; odata=verbose" },
     success: function (data) {
        if(data.d.results.length>0){

            var items=data.d.results;
            for(var i=0;i<items.length;i++){        
                    var nurl = items[i].LinkLocation;
                    var ntitle = items[i].Title.toString();

html+="<ul unselectable='on'><li class='ms-comm-adminLinksListItem' unselectable='on'><a href=" + nurl + " target='_blank' unselectable='on'>"+ ntitle + "</a></li></ul>";
      }
            html+="</ul></div>";
            $("#inserthere").after(html);
        }
     },
     error: function (data) {       
     }
    });

The problem I am facing is that the items[i].LinkLocation will have the following value "[Object]" instead of showing the real link location url value.

1 Answer 1

7

You have to drill down into the LinkLocation using:

item[i].LinkLocation.Url

As each link is an object consists of Url and Description.

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.