CSOM Archives : Binary Bits https://blog.binarybits.net/tag/csom/ Bits & Pieces - A blog by Kannan Balasubramanian Wed, 17 May 2017 07:51:02 +0000 en-GB hourly 1 https://wordpress.org/?v=6.5.2 Remove duplicate list items from SharePoint REST call result using JavaScript https://blog.binarybits.net/remove-duplicate-list-items-from-sharepoint-rest-call-result-using-javascript/ https://blog.binarybits.net/remove-duplicate-list-items-from-sharepoint-rest-call-result-using-javascript/#respond Wed, 17 May 2017 07:31:10 +0000 https://blog.binarybits.net/?p=861 The following code snippet show how to remove duplicate list items in the JSON result of a SharePoint REST call using JavaScript. Function Definition: function RemoveDuplicateItems(items, propertyName) { var result = []; if (items.length > 0) { $.each(items, function (index, item) { if ($.inArray(item[propertyName], result) == -1) { result.push(item); } }); } return result; } […]

The post Remove duplicate list items from SharePoint REST call result using JavaScript appeared first on Binary Bits.

]]>
The following code snippet show how to remove duplicate list items in the JSON result of a SharePoint REST call using JavaScript.

Function Definition:

function RemoveDuplicateItems(items, propertyName) {
    var result = [];
    if (items.length > 0) {
        $.each(items, function (index, item) {
            if ($.inArray(item[propertyName], result) == -1) {
                result.push(item);
            }
        });
    }
    return result;
}

Function Usage:
In the below code, assumption is that, the REST call returns data.d.results and the column for which duplicate items need to be removed is Title

var items = data.d.results;
items = RemoveDuplicateItems(items, 'Title');

 

The post Remove duplicate list items from SharePoint REST call result using JavaScript appeared first on Binary Bits.

]]>
https://blog.binarybits.net/remove-duplicate-list-items-from-sharepoint-rest-call-result-using-javascript/feed/ 0