You need to sign in to do that
Don't have an account?
Rama_SFDC
How to remove duplicate values in server side controller in lightning
Hi All ,
I want to display all the contact names in a drop down list but in contact list i need to remove duplicate Names .How can we achive this requirment .please find below code
public static list<contact> getconfigvalues(){
return [select id ,name from contact ];
}
var action = component.get("c.getconfigvalues");
action.setCallback( this, function(response) {
var nameresult= response.getReturnValue();
var state = response.getState();
if (state === "SUCCESS") {
for(var key in nameresult){
namelist.push(nameresult[key[0]].Name);
}
component.set("v.Name",namelist) ;
How to remove duplicate name from the namelist or Name attributr ?
I want to display all the contact names in a drop down list but in contact list i need to remove duplicate Names .How can we achive this requirment .please find below code
public static list<contact> getconfigvalues(){
return [select id ,name from contact ];
}
var action = component.get("c.getconfigvalues");
action.setCallback( this, function(response) {
var nameresult= response.getReturnValue();
var state = response.getState();
if (state === "SUCCESS") {
for(var key in nameresult){
namelist.push(nameresult[key[0]].Name);
}
component.set("v.Name",namelist) ;
How to remove duplicate name from the namelist or Name attributr ?
All Answers
Thanks for your reply .
i was tried this approch earlier ,AuraEnabled methods do not support return type of Set<String> .
is any alternative ways to remove duplicate values and i'm iterating 4 contacts fields for different drop down list.For all the fields i need to remove duplicate values .How can we achive this , please suggest any good approch this requirment
Thanks
Please correct me where did i mistake ,
var action = component.get("c.getconfigvalues");
action.setCallback( this, function(response) {
var nameresult= response.getReturnValue();
var state = response.getState();
if (state === "SUCCESS") {
var namelist =[ ];
var phonelist =[ ];
var areacodelist =[ ];
for(var key in nameresult){
namelist.push(nameresult[key[0]].Name);
phonelist .push(nameresult[key[0]].phone);
areacodelist .push(nameresult[key[0]].areacode__c);
}
}
component.set("v.Name",namelist) ;
component.set("v.phone",phonelist ) ;
component.set("v.areacode",areacodelist ) ;