Formula showing a URL with {!}

by Venkat Polisetti

Today I came across a situation where I wanted to include a field name into a formula field that returns a URL as text and will be displayed on a page layout. This URL will be used subsequently in an email template.

Here is an example of the  formula field value that I want to display on the page layout exactly as it is:

http://mysite.force.com?id={!Campaign.Id}

When you create your formula and select the formula field type as “Text” and enter the above text surrounded by single quotes, Salesforce strips the flower-brackets ‘{}’ and the exclamation mark ‘!’ around the above field when you save the formula.

I did a little experiment with the above and when I removed the closing bracket it was keeping the rest of the string untouched. So it ended up like the below:

http://mysite.force.com?id={!Campaign.Id

But, I want to have field value to have the closing } so that you can copy and paste it into an email template.

The only way that I could solve this is by adding an additional formula field that has its text value as ‘}’ (Closing_Brace__c below) and changing the the original formula like this:

'http://mysite.force.com?id={!Campaign.Id' & Closing_Brace__c

Watch the single quotes around the first part of the above formula text.

If you know a different approach to solve this, please kindly let me know through your comments below.

Thanks

About these ads

One Comment to “Formula showing a URL with {!}”

  1. Why a formula? Could you use apex as described by Salesforce as follows:
    You can set query string parameters in links to pages by constructing the link URL manually, or by using
    tags within the tag. For example, both of the following examples create identical links to an external
    page:

    Search Google

    Search Google

    The latter method, which uses tags instead of manually creating the URL, is preferable for stylistic reasons.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: