0

After reviewing my results, I realized one of the sharepoint columns only returns one value. How do I get it to return each value from my Role Column?

It should look like this:
Title: FDA Program
Roles: Project Manager, Business Analyst

Instead, it only returns this:

Title: FDA Program
Roles: Project Manager

<script type="text/javascript">
$.ajax({
    url: "https://gumdropsgc.sharepoint.com/sites/Training/_api/web/lists/getbytitle('Modules')/items?$filter=File_x0020_Name Eq 'FDAAgents'&$top=1",
    type: "GET",
    headers: {"Accept": "application/json;odata=verbose"},
    cache:false,                
    success: function(data){
        console.log(data);
        var html = "<table border='0'>";
        $(data.d.results).each(function(){
            html = html + "<tr><td>" + this.Title + "</td></tr>" +
"<tr><td><h2>" + "Roles           :" + "   " + this.Roles + "</h2></td></tr>";
        });
        html += "</table>";
        $("#listResult").html(html)
    }
});
</script>

<div id="listResult"></div>
2
  • Roles is it a multi select field? Commented Jan 14, 2015 at 19:23
  • Hmm.. I'm surprised your code works at all... What kind of field is Roles exactly? A choice field that allows multiple selections, a taxonomy field that allows multiple selections, a person field that allows multiple selections? A lookup that allows multiple choices? (if lookup include some information about the lookup target content type) In the simple case of a choice field you should be getting an array of strings inside of a results JSON container, but the fact that you're getting one value leads me to believe this isn't the case. Commented Jan 15, 2015 at 2:35

1 Answer 1

1

Try changing the url as below

url: "https://gumdropsgc.sharepoint.com/sites/Training/_api/web/lists/getbytitle('Modules')/items?$filter=File_x0020_Name Eq 'FDAAgents'&$top=1&$expand=Roles",

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.