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? – Amal Hashim Jan 14 '15 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. – John-M Jan 15 '15 at 2:35
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",

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.