Custom redirection on Lead Convert operation in salesforce.com

Standard

When you convert a Lead, you will be taken to newly created Account’s detail screen. Thats the standard salesforce.com behaviour.

But what if, you want to show newly created Contact’s detail screen (instead of Account screen), upon Lead conversion? Unfortunately, there is no such setting available in salesforce (yet).

Many people might have achieved it, by some or the other workaround. And here is my trick.

  • Create following Apex Controller class, to use it along with the VF page.
    public class LeadConvertLandingController{
    
        Id newId = null;
        public LeadConvertLandingController(){
            newId = ApexPages.CurrentPage().getParameters().get('newid');
        }
    
        public PageReference redirect(){
            Lead convertedLead = [select ConvertedContactId from Lead where id=:newId];
            PageReference pRef = new PageReference('/' + convertedLead.ConvertedContactId);
            pRef.setRedirect(true);
            return pRef;
        }
    }
    
  • Create a VF page with following markup.
    <apex:page controller="LeadConvertLandingController" action="{!redirect}">
        please wait....
    </apex:page>
    
  • Create a Custom Button for Lead object, as follows:
    • Label = “Convert”.
    • Display type = “Detail Page Button”.
    • Behavior = “Display in existing window without sidebar or header”.
    • Content source = “URL”.
    • And copy below URL in the big text area.
      /lead/leadconvert.jsp?retURL=/{!Lead.Id}&id={!Lead.Id}&saveURL=/apex/LeadConvertLanding
      
  • Now edit the Lead layout and remove the standard Convert button and add the custom Convert button.
  • Thats it!

Hope thats helpful!

Note: This solution works only when, lead conversion is done with new Account/Contact during lead conversion process. It may not work, if existing Account/Contact is chosen, during lead conversion process/screens.

Life savers – very handy apps on AppExchange

Standard

Here are some of my favorite apps on AppExchange. They are all powerful tools and most of them are free!

Draggin Role
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016a6rEAA

Manage your role hierarchy with ease! Now you can drag and drop your way through any hierarchy modifications. Draggin’ Role is a free application that allows you to view and manipulate users AND roles from a single Custom Tab.

The Permissioner
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000008XYMlEAO

The Permissioner dramatically reduces the time involved with assigning and revoking permission sets assignments to multiple users. Using a simple interface, administrators can select one or more permission sets to assign to one or more users at a time.

Steam Role
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016a75EAA

Slash administration times and have fun doing it! Drag and drop management of Roles, Territories, Users, Public Groups, Queues, and Record Ownership all from a powerful, Flash-based console. A ‘must have’ for any System or Delegated Administrator.

DemandTools
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016bXjEAI

DemandTools is an enterprise capable suite of data quality modules to control, standardize, verify, deduplicate, import & generally manipulate Salesforce and/or Force.com data. More than just duplicates removal, DemandTools is administrator productivity.

Field Trip
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003HSXEEA4

Ever wish you could run reports on the fields you have in salesforce? Take a Field Trip! This utility lets you analyze the fields of any object, including what percentage of the records (or a subset of your records) have that field populated.

Salesforce CRM Dashboards
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000004g316EAA

Your one stop shop for GREAT example dashboards. Includes dashboards for Executives, Reps, Sales, Support and more. Checkout the documentation for details.

DupeCatcher, Real Time Deduplication
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IYLlEAO

DupeCatcher enables Salesforce users to identify, block and dedupe leads, accounts, and contacts in real-time at the point-of-entry. Retain full control of the identification and merging process, eliminating any fear of loss while cleansing data.

Conga Composer
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016b7FEAQ

Easily create and deliver customized documents, presentations and reports using Word, PowerPoint, Excel, HTML email and PDF forms from standard & custom objects. Generate quotes, proposals, account plans, invoices, contracts, letters & more

Group Master
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003Jj1aEAC

The ultimate Group management tool for any Chatter admin!

Inline Account Hierarchy
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016chCEAQ

The Inline Account Hierarchy package contains a custom Visualforce component that displays the Account hierarchy as a collapsible tree. The component my be included directly into you own Visualforce pages or added to the standard account detail page.

Graphics Pack
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000004cfIcEAI

‘Graphics Pack’ contains hundreds of images / icons that can be used in salesforce applications for tabs, image formulas, and Visualforce pages

Rollup Helper
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000009i3UpEAI

Rollup Helper aggregates any Salesforce data in minutes. No coding required. Save time & money & unlock your data! Supports SUM, MAX/MIN, Formula-based Count, and Text Rollups. Rollup information using lookup relationships and through hierarchies.

Hope this helps.

Display Standard Mini Page Layout in Visualforce

Standard

Did you ever run into a situation, when you were asked to display a standard mini page layout in Visualforce, on hover of a link?

Assuming that you haven’t faced the situation, and are not sure how to go about it? Am writing this blog post, to let you know, following options available, to meet the requirement.

  1. Search and download a relevant javascript from internet, and use it in your VF page.
  2. Write your own html/javascript.
  3. Don’t reinvent the wheel. Instead, use salesforce’s standard mini page layout display mechanism.

Per my experience, options 1 & 2 are very time consuming and may not guarantee native look and feel.

However, option 3 is my favorite, as it saves lot of time and effort and is very much native. You just don’t need to write any complicated javascript/html. Instead, you will call some of the salesforce’s javascript functions. Now, that’s smart thinking.

Standard Mini Page Layout in Visualforce

Here is the Visuaforce markup, enjoy!!

<apex:page standardController="Account" recordSetVar="accounts">
<apex:pageBlock >
<apex:pageBlockTable value="{!accounts}" var="acc">
<apex:column headerValue="{!$ObjectType.Account.Fields.Name.Label}">
<a href="/{!acc.id}"
id="lookup{!acc.id}opp4"
onblur="LookupHoverDetail.getHover('lookup{!acc.id}opp4').hide();"
onfocus="LookupHoverDetail.getHover('lookup{!acc.id}opp4', '/{!acc.id}/m?retURL=/{!acc.id}&isAjaxRequest=1').show();"
onmouseout="LookupHoverDetail.getHover('lookup{!acc.id}opp4').hide();"
onmouseover="LookupHoverDetail.getHover('lookup{!acc.id}opp4', '/{!acc.id}/m?retURL=/{!acc.id}&isAjaxRequest=1').show();">
{!acc.Name}
</a>
</apex:column>
<apex:column headerValue="{!$ObjectType.Account.Fields.Type.Label}" value="{!acc.Type}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

I tried to keep it simple. However, you can create a re-usable custom component for this and use it where ever you need it.

Hope that’s helpful

Going Mobile – Technical Architect Series

Standard

Native_html5_hybridAre TAs expected to develop mobile apps?

No, they are not. However they are expected to understand pros, cons and risks associated with mobile platforms. TAs are expected to create mobile strategies while designing mobile solutions. Based on requirements, TAs are expected to zero-in on correct mobile strategy.

Why go Mobile?

Mobile apps are no longer an option, they’re a necessity now. People around the world are spending more time using mobile apps than browsing internet over their laptops or smartphones (can now be nicknamed “app phones” 🙂 )

Many enterprise companies have realized this and are now focusing on going mobile as well. And they are now willing to make their flagship products/services, available on mobile devices.

What’s inside Salesforce.com mobile SDK?

Salesforce’s Mobile SDK provides three Mobile Application Development options.

  • Native apps are specific to a given mobile platform (iOS or Android) using the development tools and language that the respective platform supports (e.g., Xcode and Objective-C with iOS, Eclipse and Java with Android). Native apps look and perform the best.
  • HTML5 apps use standard web technologies—typically HTML5, JavaScript and CSS. This write-once-run-anywhere approach to mobile development creates cross-platform mobile applications that work on multiple devices. While developers can create sophisticated apps with HTML5 and JavaScript alone, some vital limitations remain at the time of this writing, specifically session management, secure offline storage, and access to native device functionality (camera, calendar, geolocation, etc.)
  • Hybrid apps make it possible to embed HTML5 apps inside a thin native container, combining the best (and worst) elements of native and HTML5 apps.

Deciding factors

At times choosing the right option might get tricky. But if your requirements are clear and you are absolutely sure what you want? Then it becomes much easier to pick the right option. While working on your mobile strategy you will have to base your decisions on following factors (but not limited to)

  1. Platform (IOS or Android)
  2. Your development team’s skills.
    Could include HTML5, Javascript, CSS, Java, Eclipse, etc…
  3. Access to native components (like camera, calendar, etc.)
  4. Offline Data Storage capabilities.
    A must have feature when you want your users to be able to work even without internet access. And can synch  whenever internet access is available.

Here are some useful links:

http://wiki.developerforce.com/page/Mobile

http://wiki.developerforce.com/page/Webinar:_IntroMobileSDK

Hope that’s helpful.

Abstract class and Interface – Technical Architect Series

Standard

While designing any solution, we often spend good amount of time preparing coding standards, guidelines, best practices, etc… The idea behind such effort is to make sure that the chosen design is implemented with ease and quality work is delivered. Having a good design can have a profound influence on success of any implementation.

A good design needs to be robust and scalable. The code should be structured and reusable. There is no place for redundant code in a good design. Hence it is very important to understand different ways by which we can write less and reusable code.

By using Abstract classes and Interfaces developers can design robust and scalable solutions.

Are TAs expected to write classes and interfaces?
Yes in some cases and no in most cases 🙂 Even if you (as a TA) are not writing code, then you are expected to

  1. Have a clear understanding of how Abstract classes and Interfaces can be leveraged for a good design?
  2. Guide the development teams to a right design approach. If needed, teach them how to work with abstract classes and interfaces.

What is an Abstract Class?

An abstract class is just like any other class, having properties and methods. However it has following characteristic which makes it different from other classes.

  1. It can have executable methods and abstract methods.
  2. It can only subclass one abstract class.
  3. It cannot be instantiated.
  4. It can only be extended by other classes (called subclasses).
  5. Its abstract methods must be overridden by its subclasses.
  6. Its non-abstract methods cannot be overridden by its subclasses.

An example abstract class

public abstract class MasterDataHandler{
    //executable method
    public MasterDataService initMasterDataService(){
        MasterDataService objMasterDataService = new MasterDataService();
        /**
	your code goes here....
	**/
        return objMasterDataService;
    }

    //abstract method, which should be overridden by extending class.
    public abstract Boolean doSynch();
}

Examples of extending classes (sub classes)

public class AccountSynchHelper extends MasterDataHandler{
    public override boolean doSynch(){
        return true;
    }
}
public class ContactSynchHelper extends MasterDataHandler{
    public override boolean doSynch(){
        return true;
    }
}

What is an Interface?

An interface is like a class in which none of the methods have been implemented—the method signatures are there, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.  Interface has following attributes that makes it different from abstract classes.

  1. It has no implementation code.interface
  2. All its methods are abstract by default.
  3. A class can implement any number of interfaces.
  4. An interface can extend another interface.
  5. As with classes, when an interface extends another interface, all the methods and properties of the extended interface are available to the extending interface.

Please refer below links for more information

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_defining.htm
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_interfaces.htm
Hope that’s helpful.

SSL and TLS – Technical Architect Series

Standard

We talk about firewalls and proxies and their rules to secure access to your resources. But have you ever wondered, what is the underlying mechanism, to secure your traffic between requests (browser) and responses (server)? Well, the answer is Secure Sockets Layer (a.k.a SSL).

Are TAs expected to setup SSL/TLS?
Nope, they are not. However, TAs are expected to understand how SSL/TLS works. If you ever get stuck with issues related to certificates/security. You (as a TA) are expected to co-ordinate with client’s technical teams to tell them what needs to be done? to resolve the issues.

What is SSL?
TLS and its predecessor, SSL, are cryptographic protocols that provide communication security over the Internet.

SSL was developed by Netscape and if you google and check its history, you will be astonished to know that its first version  was never used and second version was hardly used and its third version (SSL3) enjoyed little adoption and usage.

And you will be equally amazed to know that actual SSL technology (developed by Netscape) is no longer used. It’s just the name that floats around but the fact is actual SSL technology is no more used. Instead a new technology has emerged and is widely used these days. It’s called Transport Layer Security (a.k.a TLS).

How do I secure my server resources with SSL?
Just install the server certificate on the server and make sure that your application applies that server certificate to itself, thats it. Your application resources will be secure. Once installed, SSL will allow HTTPS:// to function on server.

What is a certificate?
In simple words, a Certificate is block of information in a cryptographic manner, essentially telling the other computers that I am who I say I am. Certificates are used for either authenticated single sign-on with an external website, or when using your organization as an identity provider.

  • You only need to generate a Salesforce.com certificate if an external website needs verification that a request is coming from a Salesforce.com organization. (I.e. your Salesforce instance).
  • You can generate a self-signed certificate (signed by Salesforce) or a CA-signed certificate (must be sent to a CA[Certificate Authority] to sign)

What is a two way certificate or client certificate?
In some cases HTTPS:// is not sufficient. After the initial security handshake is done, the customer might expect salesforce.com to prove that it actually is salesforce.com when salesforce.com is calling a customer resource. A couple of examples of that are:

Salesforce sends client certificate as part of

  1. Outbound messages
  2. Delegated authentication callout.

Some important things to note are:

  1. In salesforce, custom client certificates can be created and used within the app.
  2. Salesforce does not expect your client applications to send client certificates to salesforce. But Salesforce does send a client certificate as part of every outbound callouts, outbound messages, etc.

How does it work?
One important ground rule is, both client and the server should support SSL/TLS for a secure communication to happen. If browser supports and server doesn’t, then the connection cannot be established and communication won’t happen.

Since protocols (HTTP, FTP, etc..) can operate either with or without TLS (or SSL), it is necessary for the client to indicate to the server whether it wants to set up a TLS connection or not. There are two main ways of achieving this; one option is to use a different port number for TLS connections (for example port 443 for HTTPS). The other is to use the regular port number and have the client request that the server switch the connection to TLS using a protocol specific mechanism (for example STARTTLS for mail and news protocols).

Once the client and server have decided to use TLS they negotiate a stateful connection by using a handshaking procedure. During this handshake, the client and server agree on various parameters used to establish the connection’s security. Here are some of the initial events that occur during a secure communication.

  1.  The client (browser) sends the server the client’s SSL version number, cipher settings, session-specific data, and other information that the server needs to communicate with the client using SSL.
  2. The server sends the client the server’s SSL version number, cipher settings, session-specific data, and other information that the client needs to communicate with the server over SSL. The server also sends its own certificate, and if the client is requesting a server resource that requires client authentication, the server requests the client’s certificate.
  3.  The client uses the information sent by the server to authenticate the server. If the server cannot be authenticated, the user is warned of the problem and informed that an encrypted and authenticated connection cannot be established. If the server can be successfully authenticated, the client proceeds to the next step.

Hope that’s helpful.

Firewalls and Proxies – Technical Architect Series

Standard

What is a Firewall?
In simple words, a firewall is something (software or hardware) which protects your resources from external world (internet).

Why Firewall?
Ask yourself these questions:
Do you leave your bank lockers unlocked?
Do you leave your car unlocked in the parking lot?
If your answer is in negative (unless you are adventurous) then, why would you want to expose your servers to the internet?
You would want to put some security to protect your server’s resources from public/internet. And at times you may want to restrict your employees from accessing certain websites. You can do that by using a Firewall.

How does a Firewall work?
Firewall works, based on pre-defined set of rules, typically done by Network Admins. These rules are instructions given to a Firewall. Based on these instructions Firewall will allow or deny access to resources.

Are TAs expected to setup a firewall?
Nope, they are not. 9 out of 10 times your customer’s Network Admins would already set this up for you. But as a TA, you are expected to understand how Firewall works. TAs are expected to co-ordinate with Network Admins to setup the Firewall rules to gain access to resources on the servers.

Why will a TA even bother about Firewall, if it’s already setup by customer’s network admins?
Well, many a times when you try to connect to an external client system from salesforce. You may hit client’s network firewall. The firewall may not allow a callout/request from Salesforce to reach client’s system. It’s because firewall doesn’t recognizes the request as a valid one. Hence you will have to instruct firewall to allow requests coming from salesforce. Meaning a new rule should be added to firewall’s rule set, where your client’s team may ask you to provide IP ranges of Salesforce’s data centers.

What is a Proxy?
In simple words, a proxy is like a middleman between two parties (systems). A proxy could be software application or a hardware device or a mix of both.

For example, if you are unable to access internet from your browser. You will go to internet options and try to check your network settings and see if your proxy setting is set properly. If you correct your proxy setting then your internet starts working. Which means if you typed google.com in the address bar and hit enter key, your request will first go to your proxy (its like you are asking your proxy to get you google.com), proxy will forward your request, get the response and send it back to your browser.

What is a Forward Proxy?
A forward proxy controls and monitors traffic from an application behind a firewall.

What is a Reverse Proxy?
A reverse proxy controls and monitors traffic from the internet that requires access to a server inside the customer’s firewall (a typical use case when working with Salesforce.com and external systems)

What are some of the Reverse Proxy use cases, from a salesforce.com implementation standpoint?
Your client might open up following services to salesforce.com via a Reverse Proxy.

  • Delegated Authentication Endpoint
  • Web services (REST or SOAP)
  • Outbound Message Endpoint
  • Email Relay

So whenever you try to hit any of the above services, your request will first land on the client’s Reverse Proxy server. And it is Reverse Proxy server’s responsibility to forward your request to appropriate services.

Here are some of the famous technologies used by enterprises. There are many more such technologies available in the market.

  • IBM DataPower
  • Layer 7 Secure Span Gateway
  • Apache Http Server – moc_proxy

What is a Proxy rule?
Proxy servers allow the admins to define a set of rules. These rules can include following (but not limited to)

  • Authentication
  • Control time of access
  • URL Filtering
    for example google.com may be allowed but bet365.com may be blocked.
  • etc….

Hope that’s helpful.

Watch out for more blog post on this TA series.

Where is the Accept button, for Lead list?

Standard

Recently someone asked me how to get Accept button for Lead/Case, on list view?

The answer could be simple. But point here is, not everyone knows that Accept button is treated differently from other standard buttons. And hence, many of the seasoned professionals too struggle to get it right first time.

People often wonder, “I have checked Accept button in the list view layout but why is Accept button still not appearing on List view?”

Standard Accept Button Checked

Well, the answer is Queues.
Just go and create a Queue for Lead/Case and Accept button will start appearing on the list view screen.

So, here are some of the steps for getting Accept button visible on list views.

Step 1: Create Queue

Create a Queue for Lead

Step 2: Go to list view
You will notice that your newly created Lead Queue appears in the list view dropdown and when selected, the Accept button is visible.

Lead Queue list view

Hope that’s helpful

Sorting, Pagination in Visualforce using DataTables JQuery plug-in.

Standard

datatables in vf

What is this DataTables.net?
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.

My Attempt
I did little bit of dotnet programming in my early days. I remember using ado.net controls for binding data to a list on an aspx page with just drag and drop. It was exciting to be able to pass SQL statements to controls directly in design time.

I always wondered if Salesforce would introduce similar VF components. For good or bad, that didn’t happen. However, Salesforce did a better thing by introducing VF components. Encouraging developers to create their our own VF components and reuse them just like you do in dotnet or java world.

Here is my attempt to create a VF component, which can take SOQL query, List of fields and Headers in design time.

I tried keep the code simple, you may tweak it as needed.

Here is the code…enjoy..!

VF Page

<apex:page docType="html-4.01-strict">
    <c:quickTableComp cContainerId="testtable"
        columnFields="Id, Name, AccountNumber"
        columnTitles="Record ID, Account Name, Account Number"
        soql="select Id, Name, AccountNumber from Account"    
    />
</apex:page>

VF Component

<apex:component controller="quickTableHandler">
    <apex:attribute name="cContainerId" type="String" required="true"  description="Id of the container which will hold & display the table" assignTo="{!cContainerId}"  />
    <apex:attribute name="soql" assignTo="{!soql}" type="String" description="SOQL query to execute and populate records." />
    <apex:attribute name="columnFields" assignTo="{!columnFields}" type="String" description="Comma-separated list of fields to display." />
    <apex:attribute name="columnTitles" assignTo="{!columnTitles}" type="String" description="Comma-separated list of column titles." />

    <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.0/css/jquery.dataTables.css"/>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
    
    <script type="text/javascript">
            $(document).ready( function() {
                $('#{!cContainerId}').dataTable();
            } );
    </script>        

    <div class="full_width">
                
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="{!cContainerId}" style="width:980px">
            <thead>
                <apex:outputPanel layout="none">
                    <tr>
                        <apex:repeat value="{!columnTitlesList}" var="t">
                            <th>
                                <apex:outputText value="{!t}" />
                            </th>                   
                        </apex:repeat>
                    </tr>
                </apex:outputPanel>
            </thead>
            <tbody>
                <apex:repeat value="{!records}" var="r">
                    <tr>
                        <apex:repeat value="{!columnFieldsList}" var="f">
                            <td>
                                <apex:outputField value="{!r[f]}" />
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>
            </tbody>
        </table>
    </div>    

</apex:component>

Apex Class

public with sharing class quickTableHandler {

    public String columnFields { get; set; }
    public String soql { get; set; }
    public String columnTitles { get; set; }

    public List<String> columnFieldsList {
        get {
            if(columnFieldsList == null && columnFields != null) {
                columnFieldsList = columnFields.split(',');
                for(Integer x = 0; x < columnFieldsList.size(); x++) {
                    columnFieldsList[x] = columnFieldsList[x].trim();
                }
            }
            return columnFieldsList;
        }
        set;
    }
    
    public List<String> columnTitlesList {
        get {
            if(columnTitlesList == null && columnTitles != null) {
                columnTitlesList = columnTitles.split(',');
                for(Integer x = 0; x < columnTitlesList.size(); x++) {
                    columnTitlesList[x] = columnTitlesList[x].trim();
                }
            }
            return columnTitlesList;
        }
        set;
    }

    public List<sObject> records {
        get {
            if(records == null && soql != null) {
                records = Database.query(soql);
            }
            return records;
        }
        set;
    }
}