• Home
  • About
    • Leadership
    • Partners
    • Blogroll
  • Force-Squared Blog
    • Tips and Tricks
    • Configuration
    • Development
  • Support
    • Knowledge Base
    • Submit a Case
  • Is It Dreamforce Yet?

X-Squared On Demand

Salesforce solutions delivered

  • Home
  • About
    • Leadership
    • Partners
    • Blogroll
  • Force-Squared Blog
    • Tips and Tricks
    • Configuration
    • Development
  • Support
    • Knowledge Base
    • Submit a Case
  • Is It Dreamforce Yet?
  • Tips and Tricks
  • Configuration
  • Development
You are here: Home / Salesforce CRM / Configuration / Convert between Business and Person Accounts (B2B – B2C)

Convert between Business and Person Accounts (B2B – B2C)

August 19, 2008 by David Schach 13 Comments

I’m a huge fan of Person Accounts (Salesforce’s phenomenal combination of Account and Contact that allows selling B2C–the best example I use is Land’s End, which sells to people). Orgs can use a hybrid model, allowing a company to track its, e.g. partner companies (B2B) and individual customers (B2C).

There is an interesting limitation to Person Accounts: They cannot be converted to B2B via the Salesforce front-end. The record type can only be changed via the API, using a tool like Data Loader or the Excel Connector. Additionally, a B2B can only be converted to a B2C if it has:

  • One Contact
  • No Parent Account
  • Nothing in Reports To on the Contact record

I set out to create a tool that would use the API to convert the record type of a B2B to B2C and back.

And there was a hitch. (There always is.) I wrote javascript buttons to be included on B2B or B2C page layouts, and it worked perfectly in my org. However, I could not upload it to the AppExchange because one cannot create a package that references B2C:

Note: You cannot upload packages that contain any of the following:
• References to person accounts, such as an s-control or custom field referencing person accounts.
• Workflow rules or workflow actions (such as field updates or outbound messages) that reference record types.

(Side note: Why not just require an org to have Person Accounts enabled, and then allow references to B2C?)

Anyway, I can’t upload the package, but I can show the code here.

  1. Create a custom button or link on the Account object. Set it to execute javascript.
  2. Paste the following code into the body and copy the appropriate RecordTypeId where indicated.
  3. Place the button or link on page layouts, and go for it! Remember to put the button to convert to B2C only on B2B page layouts, and vice versa.

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var AccountObj = new sforce.SObject("Account");
AccountObj.Id = '{!Account.Id}';
AccountObj.RecordTypeId = '0120000000000000'; // Paste B2B/C RecordTypeID
sforce.connection.update([AccountObj]);
location.reload(true);

Screenshot of code in org.


Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to email a link to a friend (Opens in new window) Email

Related

Filed Under: Configuration, Development, Salesforce Tagged With: Configuration, Force.com Builder, PersonAccount

← Activities Tabs – Enhanced View and One Set of Tabs How to Deploy QUICKLY Between Orgs →

Comments

  1. Daniel Kern says

    February 20, 2009 at 11:37

    Hi,

    We’re a non-profit that enabled person accounts. I think that we may need to stick with it and would like to hear about work you’re doing with them. This Spring 09 release scared me into thinking that we may need to go back and beg for another account with the new starter package… Thanks.

    Reply
  2. Jon Cline says

    May 26, 2009 at 15:53

    I’m a huge fan of you right now! :D

    This is so much easier than the data loader.

    I am working with non-profits who love Person Accounts as it is cumbersome at best to deal with all Donors as B2B accounts with Contacts.

    Reply
  3. Dmitry says

    July 14, 2011 at 01:10

    Great idea!

    Reply
  4. Mary says

    December 20, 2011 at 12:57

    That was insanely easy and helpful! Thank you so much!

    Reply
  5. Lauren says

    June 19, 2012 at 19:44

    Magic!! Thank you!!

    Reply
  6. boot2thhead says

    November 8, 2012 at 15:11

    Tried this and keep getting an error when I test the button. Not sure what I did wrong.

    “A problem with the OnClick JavaScript for this button or link was encountered:

    identifier starts immediately after numeric literal”

    Reply
    • David Schach says

      November 8, 2012 at 15:51

      I don’t know what that error is. Could you please paste the javascript code you’re using (with your customizations)?

      Reply
  7. Julien Camp says

    March 19, 2015 at 16:46

    Hi David,

    Don’t know if you’re still monitoring this post, but I created this button and nothing seems to be happening; just wondering what I’ve done wrong.

    Thanks if you see this!

    Best,
    Julien

    Reply
    • David Schach says

      March 19, 2015 at 17:47

      Hi Julien – thanks for the comment. Without more information, I don’t think I can help you. Post the JavaScript you’re using?

      Reply
  8. Darren Ferneyhough says

    June 21, 2016 at 09:34

    thank you – this worked just fine for me

    Reply
  9. Noga says

    September 25, 2018 at 12:39

    Hi David!
    Any idea how can we apply this functionality to Lightning?

    Thanks!

    Reply
    • David Schach says

      September 28, 2018 at 10:24

      Great question! I’ll do some looking and will see what I can come up with. Unfortunately, relying on standard tools won’t work, even with a Lightning Action.

      Reply

Trackbacks

  1. Understanding Business Accounts and Person Accounts - Part 2 says:
    May 27, 2009 at 00:09

    […] is the code courtesy of David Schach of X2OD.com: {!REQUIRESCRIPT(“/soap/ajax/13.0/connection.js”)} var AccountObj = new sforce.SObject(“Account”); […]

    Reply

Share Your ThoughtsCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Is it Dreamforce Yet?

Find out!

Find us on the AppExchange

Mass Update Contacts 2.0

Get It Now

Recent Posts

  • Prevent Duplicate Emails on Leads
  • Duplicate Record Item Enrichment and Auto-Deletion Code
  • Lightning Component With Running User Information
  • ChatterBINGO is Now Open-Source
  • Display Only My Role’s Records on a Report

Post Categories

Popular Tags

#df09 #df10 Akismet Apex AppBuilder AppExchange Appirio Astadia Blogs Chatter Configuration Content DreamFactory Dreamforce Eclipse IDE Enterprise Force.com Builder Force.com Platform Google Infowelders Integration Just for fun Lightning New Developments New Features Partner Program PersonAccount Projects Publisher Salesforce Salesforce1 Salesforce for Google Apps sfdcverse Sites Visualforce Web-to X-Squared On Demand

Find Us Online

  • Twitter
  • Facebook
  • LinkedIn
  • RSS

Subscribe

RSS Feed Comments

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 164 other subscribers

Copyright © 2008–2025 X-Squared On Demand · Genesis Framework by StudioPress · WordPress · Log in

 

Loading Comments...