Hi i want to remove duplicate records from attribute in js lightning. component.get("v.recordLeads"); I suppose we have to use lodash function here. Something like this

<aura:attribute name="recordLeads" type="Lead[]" />

var con=component.get("v.convertLeads");    
var result=  _.uniq(con);

You should be able to avoid underscore.js / lodash if you do something like this:

var uniqueObjs = {};

//create a object with unique leads
  uniqueObjs[conItem.Id] = conItem;
//reinitialise con array
con = [];
var keys = Object.keys(uniqueObjs);

//fill up con again

If some of your leads are new and don't have ids, you can sometimes make a key out of a combo of fname + lname + email (uppercased or lowercased of course)

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.