Posts

Showing posts with the label duplicate

Salesforce Fact #921 | Figuring out duplicate account names in screen flow

Image
Suppose we need to find out the duplicate account names in the screen flow. We can get that using collection filter, transform elements. In this example, we have taken two account type collection: DefaultAccCollection(which stores all the account records) and DuplicateAccCollection(which stores the account whose names are duplicate). And at the end, we can use a transform element to extract the names from collection. Attached are the screenshots.

Salesforce Fact #819 | Checking duplicates in array in LWC

Many times  in LWC or JS,  we need to check if an array of primitive types contains a duplicate or not. The indexOf() method can be used to identify the same. Example: const arr = ['a', 'b', 'c', 'a']; const result = arr.filter((row, index)=>arr.indexOf(row)!=index) if(result.length > 0){     console.log('array contains duplicate'); } else{     console.log('array does not contain duplicate'); } Reference:  https://flexiple.com/javascript/find-duplicates-javascript-array