Remove duplicates
Hi,
I was wondering if something like the following is possible?
This is obviously wrong, but i just mean in terms of the logic? Is something similar supported?
I was wondering if something like the following is possible?
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
var list = "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$top=5";
var unique = [];
$.each(list, function(index, value){
if(unique.indexOf(value.Title) === -1){
unique.push(value.Title);
}
});
return unique;
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=5";
}
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Jaitsujin,
All what is suppored is based on SharePoint's OData queries, and unfortunately, I don't think it's possible to filter out duplicates in this way - https://docs.microsoft.com/en-us/sharep ... t-requests
Plus, if there are duplicate values in the original list - it could be a problem for other use cases, such as cascading dropdowns (or even the lookup's URL leading to an incorrect item). It's best to keep the source list for the lookup clear of duplicates.
All what is suppored is based on SharePoint's OData queries, and unfortunately, I don't think it's possible to filter out duplicates in this way - https://docs.microsoft.com/en-us/sharep ... t-requests
Plus, if there are duplicate values in the original list - it could be a problem for other use cases, such as cascading dropdowns (or even the lookup's URL leading to an incorrect item). It's best to keep the source list for the lookup clear of duplicates.
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests