Skip to main content

Posts

Showing posts from October, 2015

How to find duplicates element from a list?

This is an interview question one of my colleague asked, so thought of sharing. Below is code snippet List<String> stringList = new List<String>{'One','two','Three','Four','One','two'}; set<String> setString = new set<String>(); set<String> duplicatesetString = new set<String>(); for(String s:stringList ){     if(!setString.add(s)){       duplicatesetString .add(s);    } } System.debug('duplicatelistString----'+duplicatesetString ); System.debug('duplicatelistString----'+duplicatesetString.add('ten'));

How to make Case comments as Private?

Hi All, Sometimes we don't want to display all the case comments to be visible in the portal page. A customer should see his comments and the agent's comments in the portal page. Internal user's like R&D department comments should not be visible. For that I have created a workflow to achieve this. Case comments is a child object of Case, "Is-published" is the field which specifies comments as private or public. Is-published is true means comments must be public otherwise it will be private.

How to use Like Operator in SOSL

Hi All, I have already explained about the LIKE operator in my earlier post. http://salesforceworld4u.blogspot.in/2013/08/like-operator-in-salesforce_13.html Some asked how to use Like operator in SOSL, Below is the some code snippet where Like operator being used in SOSL. Lets find account,contact,lead and opportunities records whose name is containing test keyword List<List<SObject>> searchList = [FIND 'Test*' IN ALL FIELDS RETURNING Account (Id, Name WHERE Name LIKE '%test%' limit 10),Contact(Id, Name WHERE Name LIKE '%test%' limit 10),Opportunity(Id, Name WHERE Name LIKE '%test%' limit 10),Lead(Id, Name WHERE Name LIKE '%test%' limit 10)]; Account [] accounts = ((List<Account>)searchList[0]); System.debug('Printing size-- '+accounts.size()); System.debug('Printing size-- '+accounts ); Contact [] contacts = ((List<Contact>)searchList[1]); System.debug('Printing size-- '+contacts....