Pages

Showing posts with label Lead. Show all posts
Showing posts with label Lead. Show all posts

Thursday, November 5, 2026

Salesforce: Lead merge with MCAE Prospect

Salesforce merge() SOAP API, allow to combine up to three records of the same type into one record. You explicitly tell Salesforce which record is the master/survivor and which record(s) are merged into it. Salesforce does not automatically decide that the newer or older record survives.

Let say you have Lead A, B, and C; you decide keep lead A as the master record (survivor) and merge lead B and C (victims) into lead A.

  • Keeps Lead A as the master record.
  • Merges Lead B/C into Lead A.
  • Deletes B/C as the "victim" records.
  • Reparents related records from the victims to Lead A where applicable
  • Sets MasterRecordId on the deleted victim records so you can identify what they were merged into.

Field Values

Salesforce doesn't automatically replace the master's fields with all the values from the victim. If the caller wants values from the non-master record to supersede values on the master, those field names and values must be supplied on the masterRecord in the MergeRequest.

Once the API run, you can do SOQL using queryAll() to retrieve records deleted by a merge, and MasterRecordId identifies merged records.


A few facts in the survived Lead:
  1. Lead history of victim leads will not be carried to the survived lead, so the lead history stay as per original
  2. Lead history have a new line of "Lead Merged" with original value of the victim lead name and company name
  3. Created By and Created Date is updated with the oldest victim lead
  4. All the related records (Task, Campaign Member, Messaging Session, etc.) from victim leads will be reparent to the survived lead


SOQL with queryAll():




What happened in the MCAE Prospect?
Assume both lead are in the prospect:
  • The prospect will be merged too and link to the survived lead
  • In the prospect audit, notice a line "Started matching Marketing Data Sharing criteria"
  • Created date in the survive prospect will stay as per original date, however, the conversion date and other date such as Recent Interaction will be copy from oldest victim
  • Prospect audit will have data from victim leads, including the old prospect activities


Wednesday, December 3, 2025

Salesforce: Campaign Member Deletion

Contact or Lead Deletion

When a Contact or Lead used in a Campaign Member is deleted, all Campaign Members for that lead or contact will also be deleted.

Undeleting the Contact or Lead from the Recycle Bin will restore all Campaign Members for the Contact or Lead, including the Status. However, the Last Modified Date and By of the Campaign Member record will be updated with the timestamp of when the Contact or Lead is undeleted, along with the name of the user who performed the undeletion. The Campaign Member ID will be restored to the original Campaign Member ID. 


Campaign Deletion

When a Campaign is deleted, all Campaign Members associated with that Campaign will also be deleted.

Undeleting the Contact from the Recycle Bin will restore all Campaign Members for the Campaign, including the Status. However, the Last Modified Date and By of the Campaign Member record will be updated with the timestamp of when the Campaign is undeleted, along with the name of the user who performed the undeletion. The Campaign Member ID will be restored to the original Campaign Member ID. 


CampaignMember Deletion

When a Campaign Member record is deleted, it is not sent to the Recycle Bin, so it cannot be restored. Vote for this idea.


Bonus: In the CampaignMember object, there are LeadId, ContactId, and LeadOrContactId fields. For a Lead in Campaign Member, when the Lead converted to a Contact:

  • The LeadOrContactId will be updated from LeadId to ContactId
  • The LeadId will not be changed
  • The ContactId will be populated with the Contact ID


Tuesday, July 25, 2017

Salesforce: Edit Converted Leads

If you have used Salesforce for a quite long time, you may aware that once a Lead is converted, you will not able to view the lead detail, except with report, and will not able edit it, even using API.

But, since Spring '16 Release, a user with special permission will be able to view and even edit the converted lead, directly in Salesforce page. This is a good move, in many cases Sales Ops or super user needs to edit some details in the converted lead.

In the previous blog Set Audit Fields upon Record Creation, we discussed a new permission for user able to populate Create Date, Create By, etc., but a user with the same permission "Set Audit Fields upon Record Creation" will be able to edit a converted lead too.

Thanks to Daniel Peter for pointing a new permission "View and Edit Converted Leads" introduced in Spring '17 Release, this permission reduces "Set Audit Fields upon Record Creation" permission just for the purpose of set audit fields on the record creation. I personally see this is a great approach in separating the permissions, because of the different usage.

Let's see a converted Lead in Classic, even we manually type in the URL, example: https://ap2.salesforce.com/00Q28000002fPqZ, it will be auto redirect to https://ap2.salesforce.com/p/lead/ViewConvertedLead/d?id=00Q28000002fPqZ



But, let's see when a user with "Set Audit Fields upon Record Creation" permission opens the same lead:


This user, able to see and even edit the record from Salesforce page.


Now, let's see what will be happened in Lightning for the same users. For the 1st user without Set Audit Fields upon Record Creation permission, the page will be auto redirect to the converted Contact.



While for the 2nd user with Set Audit Fields upon Record Creation permission, it will stay at the Lead page, so user able to view, and even edit the converted lead.



Editing converted Lead:




Reference:



Tuesday, November 22, 2016

Salesforce: Duplicate Management on Cross Object Duplicate Rules

Ten months ago, I blog about standard Salesforce Duplicate Management feature. This is standard feature under Data.com, but you do not need to have Data.com license to use this.

In this blog, I would like to share more about Duplicate Management on Cross Object Duplicate Rules.
Example: Email should be unique across Contact and Lead. While within the Contact and Lead itself, there are also other parameters that consider as duplicate in both Lead or Contact.

Lead duplicate matching rule:
- First Name + Last Name + Company
- Email

Contact duplicate matching rule:
- First Name + Last Name + Account
- Email

Solution:
1. Two matching rules in both Contact and in Lead

Contact: to match First Name + Last Name + Company OR Email

Lead: to match First Name + Last Name + Account OR Email

Contact: to match Email only for Lead cross object check

Lead: to match Email only for Contact cross object check


2. One duplicate rule in both Contact and in Lead

Contact duplicate rule, only can add one matching from each object


Lead duplicate rule


Note:
When edit record, Duplicate Rule will kick-in only when you update field related to fields defined in Matching Rule.

In this sample I select Fuzzy for the matching rule for First Name and Last Name, for example: Bob and Robert is considered as duplicate. But since we configure with "Allow" on create or edit, it will allow user to Save (Ignore Alert), but we can report on this with custom report type.




Reference:



Tuesday, March 29, 2016

Salesforce: Permission Change Status, Change Owner, Add to Campaign

We have case when some of our users feedback that they do not see Change Status, Change Owner, Add to Campaign button in Lead list View.



While some other users able to see that buttons.


So, what is the caused?
Change Status - to see this button, user need to have Manage Leads permission
Change Owner - to see this button, user need to have Transfer Leads permission
Add to Campaign - to see this button, user need to be Marketing User in user detail and also have Edit permission in Campaign object, this is also applicable for Contact list View.


On separate note, for custom object, user with Modify All permission for that object will see Change Owner button in the list view.




Reference:




Friday, December 18, 2015

Salesforce: Lead Source fields

When adding new Contact or Lead to a CRM system, you would like to note how you get know to that person? That's why by default Salesforce provide standard field or Lead Source is 4 main objects below, and they are picklist fields. You can customize the values based on your organization business model.
  1. Lead - Lead Source
  2. Account - Account Source
  3. Contact - Lead Source
  4. Opportunity - Lead Source
Over the time, you may modify the lead source values accordingly, but to note that: the values of 4 fields above in 4 objects above are in sync, this mean, if you add a new Lead Source value in Lead, it will copy to other objects, the same when you edit, delete and re-order values.

When you convert a Lead to Account, Contact and Opportunity, the conversion value of Lead Source from Lead will bring to Contact and Opportunity Lead Source.


Reference:


Saturday, August 29, 2015

Salesforce: Track converted Account or Opportunity from Lead

When a Lead in converted into Account, Contact and Opportunity in Salesforce, you can easily track what is the Account and Contact created (or attach to existing Account and Contact), included Opportunity created (if any). By opening the converted Lead in Salesforce, it will show you the Account, Contact and Opportunity name and link, although you will no longer see the Lead detail, except using "Leads with converted information" report.


But, looking from Account, Contact and Opportunity perspective, it is not easy to identify which of them are converted from Lead. However, if you have field history tracking enabled, looking at the object history related list will tell you if the record is created by Lead conversion or not.

Account History

Opportunity Field History

This will be not ideal if you would like to run a report of Account or Opportunity with Lead conversion information, because that information relationship only available in report with type Leads with converted lead information.

Workaround: we can built a simple solution (without code), in this scenario, we would like to report if the Opportunity is created from Lead conversion, and if yes, from which Lead.

1. Create Custom Text Field at Opportunity
Create a custom text field in Opportunity, and make sure with 15 or more characters length.

2. Create a Custom Formula Field at Lead
This formula will return in Text format. The formula would be just a simple Id that will return 15 characters length of the Lead Id, or CASESAFEID(id) to return 18 characters length of the Lead Id.

3. Map Lead Field
From Lead field setup, map custom formula field at Lead to custom text field at Opportunity, this is fields we just created above.

4. Done
Pretty easy, isn't it? From now on, we will be able to tell by running an opportunity report, if the Lead Id is not blank, the Opportunity is created from Lead conversion, otherwise it is not created from Lead conversion.


How to handle if user Clone the Opportunity?
A classic issue that we thought that the Lead Id will be bring over to the new Opportunity cloned, so the Lead Id information is no longer correct. This is only true if we add Lead Id custom text field in to Opportunity page layout.

This mean, Clone function will only clone fields that show in the page layout. By remove that field in the page layout, it will not clone Lead Id. See sample below:



As a double protection to make sure the Lead Id will never be cloned to the new opportunity:
1. Set the text field in Opportunity to 18 characters (for case insensitive Id)
2. Set the text field in Opportunity as Unique and not Case Sensitive
3. Set the formula field in Lead to CASESAFEID(id)

This will protect if in the future, someone build a custom clone functionality, system will throw error by not allowing duplicate Lead Id in Opportunity.



Thursday, June 18, 2015

Convert Lead in Salesforce1 app

As of Summer '15 release, Salesforce introduce ability to Convert Lead in Salesforce1 mobile app. If you are admin, you can enable it from: Setup - Customize - Leads - Settings, and check Enable Conversions on the Salesforce1 App.



When this is enabled, in Lead detail page in Salesforce1 app, notice a new icon "Convert".



A few items to note when convert Lead using Salesforce1 mobile app and the difference with full website:

Account 
If the Company name is match or partially match to existing Account Name, it will show in the Convert Lead page, otherwise Account name in Lead conversion page will be blank. You have option to choose an existing Account or create a new Account.

To select existing Account, tap magnifying glass icon in Account Name and search by account name.



To create a new Account, tap the magnifying glass icon in Account Name, then click New button and enter Account information. Once save, it will bring you back to Lead conversion page and the new Account created should be populated.



Opportunity


Contact

screenshot from website:

Follow-up Task



Reference:


Saturday, November 29, 2014

Salesforce: Opportunity Close Date on Lead Convert

When you convert a Lead into Account, Contact and Opportunity. Opportunity Close Date cannot be set from the Lead conversion field mapping.
  • If you are not using custom fiscal years, the Close Date of the newly created opportunity is automatically set to the last day of the current fiscal quarter.
  • If you are using custom fiscal years, the Close Date is the last day of the current fiscal period. 
  • If you are using custom fiscal years and a fiscal year has not been defined for the current date, the Close Date is the end of the current calendar quarter.

Use Case 1: set Opportunity Close Date = 90 days from Lead conversion date

Solution:
1. Create a Formula Field in Lead
  • Field Label = Now
  • Formula Return Type = Date/Time
  • Formula = NOW()
2. Create a Date/Time Field in Opportunity
  • Field Label = When Converted
  • Field Type = Date/Time
3. Map Field in Lead Conversion
  • Lead Now = Opportunity When Converted
4. Create Workflow in Opportunity
  • Object = Opportunity
  • Evaluate the rule when a record is "Created"
  • Rule Criteria - Opportunity: When Converted not equal to null 
5. Create Field Update Action in Opportunity for Workflow (4)
  • Object = Opportunity
  • Field to Update - Opportunity: Close Date
  • Formula Value = Today() + 90

Use Case 2: set Opportunity Close Date to the first day of the next fiscal quarter.

Solution: Follow step 1-4 above:

5. Create Field Update Action in Opportunity for Workflow (4)
  • Object = Opportunity
  • Field to Update - Opportunity: Close Date
  • Formula Value = CloseDate + 1


Reference: Lead Conversion Mapping




Wednesday, February 26, 2014

What happens when Lead is converted in Salesforce ?


1. Once a lead is converted, lead details are no longer visible from the Lead page payout. If you note the Lead ID before conversion, paste the Lead ID into the URL; it will show information about:
  • When the lead is converted
  • Account and Contact created or existing Account and Contact attached
  • Opportunity created
Unless the user has "View and Edit Converted Leads" permission in the profile or a permission set assigned.

2. The user can still access lead details from a report using report type Leads with converted lead information.

3. The lead is frozen; you cannot even update the lead record.

4. The Converted field is ticked, and the Converted Date field will be populated on the date the conversion happened.

5. Chatter feed posts associated with the lead are not migrated anywhere, and the lead posts are no longer available in the Chatter feed.

6. When you convert a lead into an existing contact, you are not automatically following the account. However, when you convert the lead into a new account, you automatically follow the new account, unless you have disabled Automatically follow records that I create in your Chatter settings.

7. If the Lead is associated with campaigns, all Campaign History is copied into the Contact created. For an opportunity, it will create Campaign Influence if fit into criteria, and one will be selected as Primary Campaign Source based on the latest campaign attached to the Lead.

8. All notes and attachments from the lead are converted and attached to the new account and contact (not to opportunity).

9. All open activities and activity history from the lead are converted and attached to the new account, contact, and opportunity.

10. If an existing Account has the same Company name as those specified on the lead, you can choose to attach to the existing Account, so this will not create a new Account. 

11. A lead with the same First and Last Name, but a different Company, with an existing Account will always be created as a new Contact. 

12. When a user selects to attach to an existing Account, the user will be given the option to attach to an existing Contact for the same Account only if First or Last Name is similar.

13. When you attach to an existing Account and Contact, information from the lead is inserted only into blank fields; Salesforce does not overwrite existing account and contact data. A checkbox has 2 possible values: 0 or 1, so it will never be considered a blank field, so the checkbox won't be overwritten.

14. Update Last Modified Date and Last Modified By fields on converted leads when picklist values included on converted leads are changed.

15. You can’t convert a lead that’s associated with an active approval process or has pending workflow actions.

16. By default, the Lead owner will be the record owner of the created Account, Contact, and Opportunity.

17. If you have a Record Type in Account, Contact, or Opportunity, the created record will follow the Default Record Type of the record owner as in the Profile.

18. Contact will be added in Opportunity Contact Role as Primary.

19. The Campaign Member of Lead will be linked to the converted Contact, but the LeadId value will be maintained, while LeadOrContactId will be updated to Contact ID.


Reference:



Sunday, January 26, 2014

Salesforce: Default Lead Conversion

In previous blog, we discuss about validation rule when user convert lead. Now, we have new requirement, can we set default values when user click Convert button in Lead?

By default there is no function  from Salesforce to set the default value, but there is a workaround for this, which is adding parameters to the URL. Here we go:

1. Create custom Convert button
Use this button instead of standard Convert button.
  • Go to Setup - Customize - Leads - Buttons, Links, and Actions. 
  • Click New Button or Link
  • You can select Content Source = OnClick JavaScript

  • or Content Source = URL

  • Example: if you want default "Do not create a new opportunity upon conversion" is checked, add this formula in the formula field:
    • JavaScript: window.location.href="/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&nooppti=1"
    • URL: /lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&nooppti=1

2. Edit Lead Page Layout
Remove standard Convert button and add new custom button created in Lead page layout, you can the button name  different.
  • Go to Setup - Customize - Leads - Page Layouts
  • Click Edit link for page layouts
  • Select Buttons in the layout
  • Drag and drop the button to add and remove 


Here list of parameters you can use in the custom button:
Convert Lead
  • "Do not create a new opportunity upon conversion" checked -- nooppti=1
  • "Send Email to Owner" checked -- sem=1
  • "Opportunity Name" -- noopptt={!Lead.Name} - opty
  • "Converted Status" -- cstatus=New Status
Task Information
  • "Subject" -- tsk5_fu=Mission Critical Task
  • "Status" -- tsk12_fu=Deferred
  • "Priority" -- tsk13_fu=High
Description Information
  • "Send Notification Email" -- email_followup=0
  • "Comments" -- tsk6_fu=No Comment
Reminder 
  • "Reminder" -- IsReminderSet_fu=0

You can check more fields you can pre-populate by default or if you have custom Task field to add, go to View Source by right click the page and look for name related to the field, example: <input  id="00N50000002DnFJ_fu" maxlength="200" name="00N50000002DnFJ_fu" size="20" type="text" /> For this example, the parameter would be 00N50000002DnFJ_fu=abc

Hope this help Salesforce admin.


Saturday, December 28, 2013

Salesforce: Lead Conversion Validation Rule

We blog on lead field conversion mapping sometimes back this year. In this blog, we would like to discuss how to run Validation Rules on Lead conversion process, this mean to block Lead conversion if not satisfy any rules. Few items to check:

1. Require Validation for Converted Leads
Earlier this option is called as Enforce Validation and Triggers from Lead Convert. Make sure this setting is enabled, otherwise Validation Rule on Lead conversion will be ignored. Go to Setup - Customize - Leads - Settings, enable Require Validation for Converted Leads. If you do not see this option, log a case with Salesforce support to get this option enable for you.

When this checkbox selected, it will check all validation rules in related objects of Lead conversion, including: Lead, Account, Contact and Opportunity (if Do not create a new opportunity upon conversion is not checked).



2. Set Validation Rule in Lead object
Use Case: company would like to stop lead conversion when Title is blank.
Here we go:
  • Create a validation rule in Lead using formula IsConverted
  • Make sure the rule is Active, many people forget to activate it and spend a lot of times before realize it is not active.


3. Set Validation Rule in target object
Target object here is Account, Contact and Opportunity. 
Use Case: company would like to block Account without website.
Although it is possible to create the rule in Lead, but if the validation rule in Account level, even you skip it in Lead object validation rule, validation rule in Account will take care for this.


Note:
When you have validation rule in both target, example: Account and Lead object with checking IsConverted, Account validation rule will kick-in before Lead validation rule with checking IsConverted field. This make sense because Salesforce will create / update Account before update Lead with IsConverted = True.


Reference:


Friday, November 22, 2013

Salesforce: Lead Conversion Field Mapping

When you convert a Lead, standard Lead fields automatically converted into Account, Contact, and Opportunity - as mapping below:
Lead FieldMaps to
AddressAccount: Billing Address
Contact: Mailing Address
Annual RevenueAccount: Annual Revenue
CampaignOpportunity: Primary Campaign Source
If the lead has multiple associated campaigns, the most recently associated campaign is inserted into the opportunity regardless of whether the user has sharing access to it.
CompanyAccount: Account Name
Contact: Account
Opportunity: Account Name
Opportunity: Opportunity Name
Company Name (Local)Account: Account Name (Local)
DescriptionContact: Description
Do Not CallContact: Do Not Call
This field is not updated for leads converted to existing contacts.
EmailContact: Email
Email Opt OutContact: Email Opt Out
This field is not updated for leads converted to existing contacts.
FaxAccount: Fax
Contact: Fax
Fax Opt OutContact: Fax Opt Out
First NameContact: First Name
First Name (Local)Contact: First Name (Local)
IndustryAccount: Industry
Last NameContact: Last Name
Last Name (Local)Contact: Last Name (Local)
Lead OwnerAccount: Owner
Contact: Owner
Opportunity: Owner
Lead SourceAccount: Lead Source
Contact: Lead Source
Opportunity: Lead Source
Person Account: Lead Source
MobileContact: Mobile
No. of EmployeesAccount: Employees
Partner AccountOpportunity: Partner Account
This field is not updated for leads converted to existing opportunities.
PhoneAccount: Phone
Contact: Phone
RatingAccount: Rating
TitleContact: Title
WebsiteAccount: Website

As you see from above mapping, Lead Source is only mapped to Contact and Opportunity, not to Account Source, but if you need it, here is the workaround by using custom Account Source field - Map Lead Source field on Lead object to Account Source field on Account object during lead conversion. If you aware the default Account Source picklist values are sync with Lead Source, so you may need to make sure this custom Account Source picklist values need to manually sync. At some points, Lead Source to Account Source mapping has been automated by Salesforce.

If you are not using custom fiscal years, the Close Date of the opportunity created is automatically set to the last day of the current fiscal quarter.

If you are using custom fiscal years, the Close Date is the last day of the current fiscal period. If you are using custom fiscal years and a fiscal year has not been defined for the current date, the Close Date is the end of the current calendar quarter.

Custom lead fields only can be converted into custom account, contact, and opportunity fields as specified by the system administrator (not map to the standard field). To specify the mapping for custom lead fields:
  1. From Setup, click Customize | Leads | Fields | Map Lead Fields.
  2. For each custom lead field, choose a custom account, contact, or opportunity field into which you want the information inserted when you convert a lead.
  3. Click Save.
It's best practice to map custom lead fields to other custom fields with the same field type, but here some exceptions and tightened:
  • You can only map Number to Number, Currency to Currency, and Percent to Percent field with the exact same field length and same decimal point.
  • The lookup field only can be mapped to other lookup fields with the same lookup object.
  • You can map from Text and Text Area to Picklist, even the text value does not exist in picklist value.
  • You can map from Picklist to Text, Text Area, and Long Text Area, but if the picklist value is longer than the length of the text field, it will throw system error upon conversion process - System.DmlException: Insert failed. First exception on row 0; first error: STRING_TOO_LONG
  • You can map from Auto Number, Text and Text Area to Text, Text Area, and Long Text Area field.
  • You can map from a Formula field in lead, it treats as a normal field depends on the formula return type.
  • You cannot map a Formula field into account, contact, and opportunity.
  • Standard lead picklist fields that are blank are mapped to the default picklist values for the account, contact, and opportunity (remember to check default value if you are using Record Type for the target object).

Tuesday, October 1, 2013

Salesforce: Convert Lead with Campaign Influence & Primary Campaign Source


In this blog, we are going to discuss Lead conversion and its relationship to Campaign and Opportunity.

Here is the scenario:
1. Create a new Lead

2. From Campaign History in Lead Related List, add "GC Campaign", then add "DM Campaign" with both Status = Sent.

3. Edit "GC Campaign" Status to Responded

4. Convert Lead: create new Account, Contact, and Opportunity

5. In Campaign, Lead automatically changed to Contact for both Campaign Members related list.

6. In Account, Contact added in Contacts related list, Opportunity added in Opportunities related list.

7. In Contact, both campaigns were added to the Campaign History related list, with Status and Responded brought over from Lead.

8. In Opportunity, the campaign is added as Campaign Influence related list with Contact Name, Primary Campaign Source = DM Campaign; this is because "DM Campaign" is the latest campaign attached to the Lead, although the Status is not Responded.

9. In the "DM Campaign", the Opportunity created is added in the "Influenced Opportunities" related list.

10. If the user changes the Primary Campaign Source in the Opportunity page layout from DM Campaign to GC Campaign, Opportunities in the Campaign related list move to GC Campaign as well.


Campaign Influence
System Administrators can configure Campaign Influence from Setup - Customize - Campaigns - Campaign Influence, such that only Campaigns within the last 120 days (see Specify Campaign Influence Time Frame) with the rule Responded = True will be associated with Opportunities as Campaign Influence.


Primary Campaign Source
Primary Campaign Source in Opportunity automatically refers to the last associated campaign on a lead before lead conversion, or the last associated campaign on a contact (if the contact was manually added to SFDC without being converted from a lead). See the Member First Associated field in the Campaign History related list in Contact or Lead.

screenshot from Contact / Lead

Opportunity may be influenced by more than one campaign. If you enable Campaign Influence and the campaign fits into Time Frame and Rules, when you convert a Lead, all Campaigns related to the Lead will be created as Campaign Influences in the Opportunity related list.

You can also manually associate additional influential campaigns with an opportunity, but only one will be marked as the Primary Campaign Source. A campaign manually added to an Opportunity will not be added back into the Opportunity related list in Campaign. You can view influential campaigns from the Campaign Influence related list on the Opportunity detail page.

Screenshot from Opportunity

Primary Campaign Source field on the Opportunity detail page designates the most influential campaign for that opportunity based on the data in the Campaign Influence related list.


Reference: What is Campaign Influence?


Page-level ad