Flexible Field Labels

While making a Visualforce page to display a Zip/Country -> City, State, County application, it became obvious that labeling fields manually will not satisfy all users, especially international ones.

There are a few ways to include a field and its label on a Visualforce page.

The simplest, using OutputField:
VF Page (simple):

<apex:page standardcontroller="Account">
<apex:pageblock>
<apex:pageblocksection>
<apex:outputfield value="{!Account.Name}" />
</apex:pageblocksection>
</apex:pageblock>
</apex:page>

The most common (based on code shares and other observations) method allows one to use a label other than the one in Salesforce. It also allows combining of multiple fields while maintaining the standard style:

VF Page (common, but static):
<apex:page standardcontroller="Account">
<apex:pageblock>
<apex:pageblocksection columns="1">
<apex:pageblocksectionitem>
<apex:outputlabel value="Account Name" for="an" />
<apex:outputtext value="{!Account.Name}" id="an" />
</apex:pageblocksectionitem>
<apex:pageblocksectionitem>
<apex:outputlabel value="City, State, Zip" for="csz" />
<apex:outputtext value="{!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}" />
</apex:pageblocksectionitem>
</apex:pageblocksection>
</apex:pageblock>
</apex:page>

And a way to allow field label renaming and translations:

VF Page (more flexible, allowing for renaming and translations):
<apex:page standardcontroller="Account">
<apex:pageblock>
<apex:pageblocksection columns="1">
<apex:pageblocksectionitem>
<apex:outputlabel value="{!$ObjectType.account.fields.name.label}"  for="an" />
<apex:outputtext value="{!Account.Name}" id="an" />
</apex:pageblocksectionitem>
<apex:pageblocksectionitem>
<apex:outputlabel value="{!$ObjectType.account.fields.billingcity.label}, {!$ObjectType.account.fields.billingstate.label}, {!$ObjectType.account.fields.billingpostalcode.label}" for="csz" />
<apex:outputtext value="{!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}" id="csz"/>
</apex:pageblocksectionitem>
</apex:pageblocksection>
</apex:pageblock>
</apex:page>

So by using $ObjectType.account.fields.billingcity.label (and similar markup for other objects and fields) we can allow org-specific customizations to come into our code with no effort required.

There’s a catch (there always is). Note that there is no way to combine the three fields for City, State, and Zip (while using automatic renaming to help us with any customizations that the org has made) while maintaining proper labeling. In this case, the label for the combined field would be “Billing City, Billing State, Billing Zip/PostalCode.” In other words, we can use whatever the org prefers for each field, but the developer must choose the label, which must remain static.

The more astute administrators and developers will note that there is a solution available: Use a component and pass the field labels displayed to the component. Then, using custom labels and translations, the component could be made truly international. This is, however, beyond the scope of this post. But it is an idea for a future post…

And the most astute amongst you are probably saying, “A truly flexible labeling system would allow the word “State” for a US address, “Province” for Canadian and others, and would still be completely customizable and translatable. Yes, that would be nice. :)

 

Summer ’09 Logo Unveiled

March 20, 2009 by David Schach · Leave a Comment
Filed under: salesforce.com 

The voting is over and we have a winner.
Salesforce has released the official logo for the Summer ’09 (release 160) logo: The sailboat.

The Salesforce CRM Summer 09 final logo




Read more

 

X-Squared featured in Inc.com article on drop.io

March 19, 2009 by David Schach · Leave a Comment
Filed under: X-Squared On Demand 

Those who follow us on Twitter know that drop.io is one of our favorite tools. We use it to collaborate with clients, to send files without taking up valuable inbox space (companies have been known to enforce miniscule Exchange inbox sizes), and even to share music playlists.
Howard Greenstein of Inc.com published a story today(“Stop, Collaborate, and Listen“) on drop.io and asked David to comment on how drop.io can help SMBs in service delivery.
It’s a good story that outlines the more basic features that drop.io offers. There is so much more available, both through the front-end and via drop.io’s RESTful API. In fact, David has been working on a Salesforce-drop.io integration that will allow inexpensive file storage and selective file-sharing with clients.
Please read Howard’s story and give drop.io a shot – you’ll enjoy it.

 

Zip to City & State Integration – Proof of Concept

March 11, 2009 by David Schach · 2 Comments
Filed under: salesforce.com 

Zip to State & City - Proof of Concept

This is proof that our newest project, an integration to retrieve the State and City based on a postal code, works... sometimes. Obviously not ready for public consumption yet.

 

  • Recent Posts

  • Subscribe

  • Post Categories