Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I wanted to add a simple read-only URL-field to 'opportunities' in SalesForce that contains a link to an external webpage with the 15-char record id (used in the salesforce urls) attached to it . To do this I wen to /ui/setup/Setup?setupid=Opportunity --> fields and created a new field under 'Opportunity Custom Fields & Relationships'.

I chose a field with data type 'URL' and added a default value. I thought
""&id would do the trick, but this returns

Error: Field id may not be used in this type of formula

This is a vague error. Is my syntax of a default value wrong, or am i using the 'id' parameter in a wrong way? And what is the right way to do this?

I'm new to SalesForce, as you probably already have guessed.

1 Answer

0 votes
by (32.1k points)

To start with, read some of the documentation on default fields. Pay precise attention to the order of operations:

  1. The user decides to create a new record.
  2. The default field value is executed.
  3. Salesforce presents the edit page with the default field value pre-populated.
  4. The user enters the fields for the new record.
  5. The user saves the new record.

Default field values are calculated before any other record data including the id are available. For this reason, they can't be calculated based on other record fields. Especially the record id, which has not yet been assigned.

To get this functionality, you will need to create a workflow rule that fires on record creation and inserts the proper value into your field.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce developer certification.

Browse Categories