function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Formula field stripping multiple spaces

Trying to create a formula field that formats a set of fields for output in a fixed format. e.g.


RPAD(Name, 25) & RPAD(Phone, 20) & RPAD(Fax, 20)


When we view the data output all the spaces are automatically trimmed to a single space (i.e. Bloggs Inc 01299 999999 01299 888888). We changed this to use a custom field populated by a workflow instead. The field displays with the spaces trimmed again but is correct when we Edit the record.


Anyone know how to get the formula field to output correctly ?

Shannon HaleShannon Hale

This is because HTML automatically suppresses extra blank spaces when it renders the content in a web browser. The only way around that is to wrap the content in <PRE></PRE> tags or replace the spaces with HTML non-breaking space characters, neither of which can be done in a formula field because markup isn't allowed.


You might be able to create a Visualforce page that has something like the following in it (I'll warn you that Visualforce is not my strong suit so you might want to ask around on the Visualforce board):


<apex:page standardController="Account">
<apex:variable var="a" value="{!Account}"/>
  <apex:outputField value="{!a.Formula__c}"/>


and then include the Visualforce page as a component in your page layout.