Monday, September 20, 2010

Storing a Website URL for use in Custom Email Templates

In Salesforce setup, most users are familiar with the “Organization” object, which stores basic organizational information such as address, time zone, and phone numbers. Well it’s my understanding whoever created this object was designing applications for companies stuck in 1980 who don’t have websites. The URL for an organization’s website is a critical piece of organizational information that most companies want to have available on emails and other system templates.
Unfortunately, custom fields cannot be added to the organization object, making it impossible to do what would seem most intuitive - create a URL field to store a company website on the Organization object. A workaround we’ve used to circumvent this limitation is to do the following:
Step 1: Create a Custom Setting to Store the Company Website URL
Simply create a new custom setting. Keep the default setting type of hierarchy and set the visibility to Public. Once the setting has been created, add a new custom field to the setting. It should be created as type “URL” (it will look something like the image below when you’re done).

Don’t forget to save an actual website URL in the field once you’ve saved it.
Step 2: Add a Custom Field to the User Object to Reference the Custom Setting
Next, simply go to the user object and add a custom field of type “formula”. In the simple formula area, reference the custom setting that was created in step 1. Your reference formula should be in the format of:
$Setup.CustomSettingAPIName.CustomSettingFieldAPIName
            Save the custom field when you’re finished.
            Step 3: Reference the User Website Field in a Template
Now, referencing the company website URL in an email template is easy! Since each user in the system now has the website stored in a custom field, the website URL can be accessed through any system user. Luckily, a field type called “Sending User” is available for use on any template. You can now place a website URL in a template by using the following merge field:

No comments:

Post a Comment