Giter VIP home page Giter VIP logo

rahman123 / sfdc-lead-conversion-record-types Goto Github PK

View Code? Open in Web Editor NEW

This project forked from douglascayers/sfdc-lead-conversion-record-types

0.0 2.0 0.0 79 KB

Workaround for Salesforce Lead Conversion process to allow administrators more control of how record types apply to converted accounts, contacts, and opportunities.

License: BSD 3-Clause "New" or "Revised" License

Apex 100.00%

sfdc-lead-conversion-record-types's Introduction

Update

Back in 2014 there was no Process Builder, so our only options for assigning record types on lead conversion were Workflow Rules and Field Updates or Apex Triggers, like this one. Since then, Salesforce released in Winter '16 Process Builder that lets us solve this problem with clicks-not-code. The code is here if you'd like to use it, but for new folks I recommend checking out my blog post on Advanced Lead Conversion Using Process Builder.

Lead Conversion

Deploy to Salesforce

As of this writing, the Salesforce Lead Conversion process does not allow users to pick the record types for the converted accounts/contacts/opportunities.

Salesforce instead uses the 'default' record type for those objects of the user's profile who is performing the conversion. This assumption is not always valid, particularly for users that have multiple record types available to them or that the ones they use aren't actually flagged as 'default' on their profile (for example, the user's profile has the master record type as default but the record types they actually use are granted through permission sets).

This trigger is a workaround that leverages a custom setting to provide administrators a way to provide simple one-to-one record type conversion mappings while still using the out-of-the-box lead conversion page.

Simply put, this trigger looks up a xref from the custom setting based on the lead's record type then for each converted object (account, contact, opportunity) it updates their record types to the values specified in the custom setting.

On the Salesforce Success Community, the ability to choose a record type is a highly requested feature, and I hope that this workaround will eventually not be necessary:

Read the Salesforce Docs on Lead Conversion Process to learn more:

Prerequisites

Before attempting to deploy these customizations, please ensure that custom record types exist for Account, Contact, Lead, and Opportunity objects. In my unscientific testing, the recordTypeId field on sobjects is not available unless custom record types exist, which will cause the apex tests to fail during deployment. This is a common "gotcha" when deploying this into new orgs. First reported by @rsmithdev6.

Getting Started

To implement this workaround in your salesforce org you will need to create a custom setting and deploy the apex classes in this repository. The steps are very easy to do, and I'll outline the basic steps below.

  1. Create a Custom Setting
  2. Create an Apex Class
  3. Create an Apex Trigger
  4. Create an Apex Test

Create Custom Setting

The custom setting is our cross-reference mapping between Lead record types and Account, Contact, and Opportunity record types that we want to leverage during lead conversion process.

custom settings

Manage Custom Setting

Once the custom setting is defined, from its detail page click the Manage button to add some mappings. You will create a new instance of the custom setting for each of your Lead record types. The name field of the custom setting will hold our Lead record type names and the three fields on the custom setting will hold the names of the actual record types we want to use for those sobjects during lead conversion. If you don't use Opportunities then that field can be left blank. It is only used by the code if the lead converted into an opp.

manage settings

Installation

  1. Easily deploy this customization to your org with the GitHub Salesforce Deploy Tool authored by Andy Fawcett
  2. Configure the Custom Setting as described above with appropriate lead, account, contact, and opportunity record types

sfdc-lead-conversion-record-types's People

Contributors

douglascayers avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.