Monday 22 May 2017

How to avoid hard coded record type id from Validation rule ?

Hi All,

It is not best pratice to use hard coded id value in validation rule or in any formula field logic, because ID value will keep on changing form environment to environment.

if we use hard coded id then it will cause lot of maintenance activity. Here is an example where hard code Id value is being used and how to achieve without using hard code value.


AND( ISBLANK(CustomField__c ), 
RecordTypeId ='0124B0000004aZ4', 

OR(ISPICKVAL(Type, 'New'), 
ISPICKVAL(Type, 'Reserved')), 
NOT($Profile.Name ='Integration Admin'))

Instead of recordtypeid it is better to use Recordtype.developername.

AND( ISBLANK(CustomField__c), 
RecordType.DeveloperName ='Marketing_Event', 
OR(ISPICKVAL(Type, 'New'), 
ISPICKVAL(Type, 'Reserved')), 
NOT($Profile.Name ='Integration Admin'))

3 comments:

Unknown said...

Hai Author, Very Good informative blog post,
Thanks

Jaweed Khan said...

This is an best post. It is Really very informative concept.I like it and help me to development very well.Thanks alot for this brief explanation and very nice information.sales force online training

vijay said...

Great job. It’s amazing. You can make information unique and interesting. After reading this article I just wanna say one word Thank you for giving these wonderful offers for those who are willing to learn.
Salesforce Training in Chennai

Salesforce Online Training in Chennai

Salesforce Training in Bangalore

Salesforce Training in Hyderabad

Salesforce training in ameerpet

Salesforce Training in Pune

Salesforce Online Training

Salesforce Training