Convert between Business and Person Accounts (B2B <-> B2C)

August 19, 2008 · Filed Under Configuration, Development, salesforce.com · 3 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.

Screenshot of code in org.


Activities Tabs – Enhanced View and One Set of Tabs

August 14, 2008 · Filed Under Development, salesforce.com · 6 Comments 

What was I thinking? Using something as complicated as a hijacked (from the Console) Task view was bound to have problems when creating an Activities tab.

Let’s restate our goals:

  1. Create a tab that will show Activities, using the Enhanced Lists view.
  2. Don’t have two rows of tabs at the top of the page.

Question: Is there any way to make a view and to specify that we don’t want to see the Sidebar AND the Tabs?

Answer: YES. The answer is Visualforce!

We will use Visualforce’s iframe tag to fool the UI into thinking that it’s displaying a URL other than the one it thinks it’s displaying.

Step 1: Enable Developer mode. Then create a Visualforce page. I called mine Activities, so the URL is [instance]/apex/Activities

<apex:page standardController="Event" tabStyle="Event" sidebar="false" showHeader="false" name="Activities" label="Activities">
<apex:stylesheet value="/dCSS/Theme2/default/common.css"/>
<apex:panelGrid width="100%" columns="1" id="exitLink" bgcolor="#EFEFEF">
<apex:outputLink value="/home/home.jsp" id="homeLink">Exit this view</apex:outputLink>
</apex:panelGrid>
 <apex:iframe src="/007" height="900px" scrolling="true" id="theIframe"/>
</apex:page>

Notes on the code:

  • If you remove the height tag, it defaults to 100%, but that’s in relation to the number of rows in your list. So the Sidebar may be cut off if you have too few rows. Stick with a standard height. I chose 900 because I assume that most screens are 1280×1024 resolution, minimum.
  • I used 007 (the object ID for Activities), but I could have used 00T (Tasks).
  • If you click on anything in the page, the URL will remain /apex/Activities. This is because you are technically working within an IFrame. This is the reason for the Exit link.
  • The code calls the standard stylesheet so that it comes up in Salesforce’s preferred Arial font instead of Times New Roman.
  • I created a table with one column for the Exit link so that I could color the background of the link the same as the top of a Salesforce page; this is purely for cosmetic reasons.

Now we’ll create a Visualforce Tab:

Setup -> Create -> Tab
Scroll to the bottom of the page
New Visualforce Tab
Select the Activities page from the picklist
Name: Activities
Label: Activities
Choose an icon (I liked the whistle) but keep in mind that it doesn’t matter because we’re using the Events controller, so the page will have the Events green color.
Finish the wizard, and you’re done!

Here are my favorite parts of the setup:

  • It uses Visualforce.
  • A standard controller means no Apex classes are required.
  • The code can be used in any org as-is.
  • We use a full-sized IFrame to fool the Visualforce page into thinking that it’s displaying something other than a fully customized VF view!

Zipcar: CaaS (Car as a Service)

August 13, 2008 · Filed Under Companies, X-Squared On Demand · 1 Comment 

A few weeks ago, I went on a Low Car Diet. No, I didn’t come up with the name; it’s the invention of Zipcar, a growing company with a product that, in these times of rising gas prices, is not only filling a growing demand, but is creating a market for its service.
After speaking to some people at Zipcar, and having rented cars a few times, I have come to realize the following:
In this age of Web 2.0 (and, according to some, Web 3.0), when Software as a Service is growing faster than ever, the on-demand model can be applied to other sectors, creating, for instance, Car as a Service.
OWN NOTHING
Ask anyone who drank the Software-as-a-Service Kool-Aid about in-house servers and you’ll be greeted with a face that looks like someone just took a bite out of a lemon, peel and all. In today’s quickly-evolving Information Technology world, ownership is nothing; rental is everything. How much does it cost to own a file server (including hardware, electricity, air conditioning, salaries for the in-house geeks, space that can’t be used for an office refrigerator, and more) per year? Compare that to the cost of storing files on Amazon Web Services! Compare purchasing a VPN appliance to the monthly cost of certificate-based Single Sign-On products like MyOneLogin by TriCipher. Pooling capital costs and being charged only for what we use is the new model. I don’t want to have to buy a 1TB NAS drive, and then to worry about if it is filling up; I’d rather pay per GB for shared storage, where my information is just as private, and arguably more accessible while being more secure (since nobody can walk into my office and steal my drives).
Cloud Computing is where it’s at. This is the solution to problems caused by using in-house systems and desktop applications inaccessible from any computer outside the office. And Cloud Driving seems to be just as viable a solution to the headache of owning a car and paying for gas, insurance, parking, and maintenance.
Let’s compare Salesforce, the top on-demand software application created by salesforce.com to Zipcar, a leading on-demand driving service created by, well, Zipcar. Read more

Google Docs Now Has Templates for Google Apps

I use templates for most of my documentation–it’s just easier to write a ROF or a configuration plan when all the standard information is already there. Up to this point, short of using Salesforce Content or DreamTeam, I haven’t seen many options for version control through Salesforce. Until now.

Google Docs has templates, and those of us using Google Apps with our Salesforce org (which should be almost everyone, since it’s free and easy to use) can design company-wide templates. This, combined with Google Docs’ super collaborative features, should make things much easier for consultants.

Here’s my wishlist for this feature: Use the Google-Salesforce Toolkit to create a spreadsheet with each worksheet representing an object and each row a field. (It would probably use a Describe function, etc.) Include columns for things like label, name, length, type, picklist values, etc. I don’t know how to code it myself, but it would be awesome to use. If we had one for a fresh, pristine org as a template, then we could use that for requirements-gathering with clients, creating the template in Google Docs and then doing the configuration based upon that spreadsheet.

Activities Tab in Salesforce

August 3, 2008 · Filed Under Configuration, Native Application · 3 Comments 

To display a tab of Activities, just like you can with Accounts, Opportunities, etc., use the following URLs in the Web Tab configuration screen:

/home/actlist.jsp?isdtp=mn

  • Displays a full-page list of Activities (Tasks and Events)
  • The list is non-enhanced, even when viewed in an “enhanced lists” org.

/home/actlist.jsp

  • Displays Activities with the Sidebar and Tabs

these are especially useful if you have Enhanced Lists enabled – it looks amazing. Create additional views for Tasks or Events, and then save the URL for each as its own Web Tab as desired.
(For example, in my org, My Open Tasks is https://na1.salesforce.com/007?fcf=00B30000005UoEi – I made a Web Tab and in the URL put “/007?fcf=00B30000005UoEi.” Worked perfectly.

Enjoy!

Addendum: To prevent multiple rows of tabs at the top of the page, you can launch the tab from a link. The best way to do this is to put a custom link in your sidebar and to view the tab that way.

Addendum 2: Kudos to Andres G for noting that the ?idtsp=mn version looks like the Salesforce Console–it absolutely does! There was a discussion on the developer boards.

Also, Scott Hemmeter blogged about this a while back and included some javascript to get around the double-tabs problem.

My next Visualforce coding project will be to create this using VF, likely based on Ron Hess’ code example.