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.
- Create a custom button or link on the Account object. Set it to execute javascript.
- Paste the following code into the body and copy the appropriate RecordTypeId where indicated.
- 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);
Daniel Kern says
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.
Jon Cline says
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.
Dmitry says
Great idea!
Mary says
That was insanely easy and helpful! Thank you so much!
Lauren says
Magic!! Thank you!!
boot2thhead says
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”
David Schach says
I don’t know what that error is. Could you please paste the javascript code you’re using (with your customizations)?
Julien Camp says
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
David Schach says
Hi Julien – thanks for the comment. Without more information, I don’t think I can help you. Post the JavaScript you’re using?
Darren Ferneyhough says
thank you – this worked just fine for me
Noga says
Hi David!
Any idea how can we apply this functionality to Lightning?
Thanks!
David Schach says
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.