Tuesday, May 7, 2013

Salesforce validation rule or workflow, use 15 or 18 characters Id?

Each Salesforce Id will have unique 15 or 18 characters. What is the different?
15 characters for case sensitive and 18 characters for case insensitive.
You also can use build-in function from Salesforce to convert 15 to 18 characters Id using CASESAFEID(Id) function.
See sample below:
00180000010shNA --> 00180000010shNAAAY
00180000010shNa --> 00180000010shNaAAI

There are few website provide tool to convert from 15 to 18 characters, example:

In this blog, I would like to share on using Salesforce Id on validation rule and workflow.

1. Only 15 characters Id will work in Validation Rule or Workflow
Test on 15 and 18 characters of Salesforce Id in validation rule and Workflow. Validation rule and Workflow only work with 15 characters Id, NOT in 18 characters Id.

2. Suggest to use $Profile.Name instead of using $Profile.Id or $User.ProfileId

See 2 validation rules below, which one is better (make our life easier) ?
ISPICKVAL(PRIORVALUE(StageName), "6 Close - Lost") 

NOT($Profile.Name="Regional Sales Ops"), 
NOT($Profile.Name="Global Sales Ops"), 
ISPICKVAL(PRIORVALUE(StageName), "6 Close - Lost") 

3. Use = instead of == 
Both == and = is working, but SFDC suggest to use = ; It's good idea to make it standard to use only =