Converting a 15-digit Salesforce opportunity ID to 18 digits using a formula field

Internal record IDs in salesforce.com, as found in all custom and standard objects such as the opportunity, account, contact, and so on contain 15 character text-based values.

The text values can be described as a base-62 number as each of the individual 15 characters can be either a numeric digit (in the range 0-9), a lowercase letter (in the range a-z), or an uppercase letter (in the range A-Z).

These 15 character salesforce.com values are therefore case-sensitive, since there can be two unique IDs which owe their uniqueness to the fact that they have a character(s) that differs only in case. For example, 100000000000ABC is different to 100000000000abc.

However, there are applications such as Microsoft Excel, which are not case-sensitive, that do not recognize the difference between the ID 100000000000ABC and the ID 100000000000abc. This results in features such as the Excel function VLOOKUP, failing to match correct records from an exported salesforce.com report.

Salesforce.com realized the potential problem where the case of the source lookup value is not processed correctly within external applications that are not case-aware.

To provide better compatibility between salesforce.com and tools such as MS Excel, MS Access, and SQL Server salesforce.com has established an 18-character case-insensitive ID that is formed by adding a suffix to the 15 character ID, a method that respects the case-insensitive nature of these tools.

In this recipe, we will convert a 15-character case-sensitive ID to an 18-character case-insensitive ID.

How to do it...

Carry out the following steps in order to convert a 15-digit Salesforce opportunity ID to 18 digits:

  1. Navigate to the opportunity customization setup page, by going to Your Name | Setup | Customize | Opportunities | Fields.

    Note

    Scroll down to the Opportunity Custom Fields & Relationships section.

  2. Click on New.

    Note

    Here, we are presented with the Step 1. Choose the field type page.

  3. Select the Formula option.
  4. Click on Next.

    Note

    Here, we are presented with the Step 2. Choose output type page.

  5. Type Opportunity ID (18 Chars) in the Field Label textbox.
  6. Click on the Field Name textbox. When clicking out of the Field Label textbox the field name is automatically filled with the value Opportunity_ID_18_Chars.
  7. Set the Formula Return Type value as Text.
  8. Click on Next.

    Note

    Here, we are presented with the Step 3: Enter formula page.

  9. Paste the following code:
    CASESAFEID( Id )
  10. In the Blank Field Handling section, select the option Treat blank fields as blanks.
  11. Click on Next.

    Note

    Here, we are presented with the Step 4. Establish field-level security page.

  12. Select the profiles to which you want to grant read access to this field via field-level security. The field will be hidden from all profiles if you do not add it to field-level security.
  13. Click on Next.

    Note

    Here, we are presented with the Step 5. Add to page layouts page.

  14. Select the page layouts that should include this field. The field will be added as the last field in the first two-column section of the selected page layouts.
  15. Finally, click on Save.

How it works...

The formula field appears on the opportunity detail page and displays the 18-character ID. You can see how this ID compares to the 15-character ID that is generated within the web URL as shown in the first red-circled section of the following screenshot:

How it works...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.165.115