Skip to main content

Posts

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....

How will external system get SFDC service endpoint URL dynamically

Hi All, This post is all about to avoid an integration issue(Service not available or invalid session id) when instance url get changed in SFDC. From SFDC side no need to perform any action ,but we can suggest appropriate approach of fetching endpoint url to external system so that communication will be smoother. For an inbound integration SFDC has to provide two WSDL to external system. Partner WSDL (Required to generate session id ) Service WSDL In the service wsdl the endpoint URL will be <soap:address location=" https://cs15.salesforce.com/services/Soap/class/YourWebserviceClassName "/> So the external system will add endpoint URL in a property file or in some in configuration stuff, that is how webservice works.As we all know instance ( cs15 ) used to change from environment to environment (QA to UAT), and instance will  also change when SFDC plan for refreshment of server. At that time we have to update external team about the new url otherwise the...

How to make pageblock section to be collapsed by default

Hi All, We can achieve it through java script. <apex:page standardController="Account"> <apex:form> <apex:pageBlock id="block1">     <apex:pageBlockSection id="section1" columns="2" collapsible="true" title="Collapsebale Section">         <apex:inputField value="{!Account.Name}"/>          <apex:inputField value="{!Account.Phone}"/>     </apex:pageBlockSection>      <script> twistSection(document.getElementById('{!$Component.block1.section1}').getElementsByTagName('img')[0]) </script> </apex:pageBlock> </apex:form> </apex:page> Normal Section Collapsed Section  

How to Override Go button in SFDC(Overriding List view In SFDC )

Hi All, I had come across a scenario like to override a button so called "Go" in standard page.As we all know,when Go button clicked,it will always navigate to sfdc standard list view. What if you want to navigate to your custom page? How can we achieve it? It is very easy, please go through below image.

Hyperlink formula is not working(Instance URL is getting appended along with the external link)

HI Guys, This post is regarding an issue i had come across at my development work. I had to display a hyper link to navigate to some other site from a standard layout. That link varies from record to record. So I created a text field(Brass_Link__c) to store the link and created a hyperlink formula field(Brass_Hyper_formula__c) to display "view " as link if text field is having some value. Below is the formula field logic IF(BRASS_Link__c <> null, HYPERLINK( BRASS_Link__c , "View"), "") BRASS_Link__c - Stores link  How will we solve above issue? Its quite simple change the link from www.google.com to  https://www.google.com