Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get unique/distinct column values via rest - SharePoint Online

$
0
0

Hi All,
Im trying to use the code below to retrieve duplicate valuesof the Line field in my sharepoint list 

function getListItems(url, listname, query, complete, failure) { $.ajax({ url: url + "/_api/web/lists/getbytitle('" + listname + "')/items" + query, method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { complete(data.d); }, error: function (data) { failure(data); } }); } getListItems('https://site','Test','?$top=5', function(items){ //I can get the arrays here, how can i retrieve the item values console.log(items) var Names = groupBy(items,'Line');

//This give me undefined error console.log(Names) }, function(error){ console.log(JSON.stringify(error)); } ); function groupBy(items,propertyName) { var result = []; $.each(items, function(index, item) { if ($.inArray(item[propertyName], result)==-1) { result.push(item[propertyName]); } }); return result; }




Viewing all articles
Browse latest Browse all 7589

Trending Articles



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