Dynamic Account Search

Dynamic Account Search

Apex
Dynamic Account Search I had a business requierment that was involving coding a controller in combination wiht a Visualforce page. The idea was to enable users to dynamically search for accounts. Looking for some ideas I found a really nice example from Jeff Douglas, you can find it here. So I took this structure and build my own page. The most interesting part of this code is the fact that you don't event need to click a "search" button to start retriving results. As nice as that can be there are other things that I really like about this code. The simplicity and efficiency of this code are really outstanding, that is why I want to share this with you, all credit goes to Jeff of course ... I'm just a messenger.  …
Read More
You got to love them, Maps ..

You got to love them, Maps ..

Apex
Maps vs For loops, Round 1 In this example I want to use a technique that will help us to avoid inserting for loops inside other for loops. Let's say you want to compare a couple of fields from different objects, in many situations you will find something similar to this: [code lang="php"] //SOQL queries to retrieve our values List<Lead> leadList = [SELECT Id, Email FROM Lead WHERE Email!= null]; List<Contact> contactList = [SELECT Id, Email FROM Contact WHERE Email != null]; for(Lead l: leadList) { for(Contact c: contactList) { if(l.Email == c.Email) { system.debug('There are emails matching: ' + 'Contact Email:' + c.Email + ' with Lead Email: ' + l.email); } } } [/code] If you run this code in an anonymous window it will run fine. The…
Read More
Wrapper Class

Wrapper Class

Apex
Wrapper Class A Wrapper Class is an extremely useful class that you can use when you need to group a number of objects in one "container". You will be using this class especially in Visualforce controllers. A more technical definition will be something like: "A wrapper or container class is a class, a data structure, or an abstract data type whose instances are collections of other objects" It is just a temporary container that can hold objects with their records for further calculations or logics within your code structure. We are going to build a table in a Visualforce page and display Contact and Account information in that same table using a wrapper class. Here is the initial class, class name WrapperDemoController and like you can see it contains on…
Read More