function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alulalul 

Make account name field read-only on certain account record types

Hello,

 

Our team has built a validation rule to make the account name field read-only for all users (except administrators) and for certain account record types.  Here is what we have:

 

OR (
(AND (ISCHANGED (Name ), $RecordType.Id != '01240000000M1ug')) ,
(AND (ISCHANGED (Name ), $RecordType.Id != '01240000000M1uW')) ,
(AND (ISCHANGED (Name ), $RecordType.Id != '01240000000M1ub')) ,
(AND (ISCHANGED (Name ), $Profile.Id !='00e30000000eaLa'))

)

 

I tested this logic by logging in as a non-adminstrator and went to an account where it's a record type that I should be able to edit.  When I try to edit the account name on one of these record types, I still get an error.  Is there another way I can exclude these record types so all users can edit the account name if it's a select record type?

Best Answer chosen by Admin (Salesforce Developers) 
alulalul

Thanks for the reply.  Premier support actually got back to us last night and provided us with this solution:

 

AND(

 

CASE( $RecordType.Id,

'01240000000M1ug',1,

'01240000000M1uW',1,

'01240000000M1ub',1,0)=1,

ISCHANGED (Name ),

$Profile.Id <>'00e30000000eaLa')

 

This seemed to do the trick.

All Answers

Jeremy.NottinghJeremy.Nottingh

You've got your criteria set up as OR, which means if any one of them is true, the validation rule fires. Try this, it will only run if ALL criteria are TRUE. In other words, it will allow editing if any of these is false.

 

(AND 

  ( ISCHANGED(Name),

  $RecordType.Id != '01240000000M1ug',

  $RecordType.Id != '01240000000M1uW',

  $RecordType.Id != '01240000000M1ub',

  $Profile.Id !='00e30000000eaLa')

 

If I understand your case right, this should do the trick.

 

Jeremy

alulalul

Thanks for the reply.  Premier support actually got back to us last night and provided us with this solution:

 

AND(

 

CASE( $RecordType.Id,

'01240000000M1ug',1,

'01240000000M1uW',1,

'01240000000M1ub',1,0)=1,

ISCHANGED (Name ),

$Profile.Id <>'00e30000000eaLa')

 

This seemed to do the trick.

This was selected as the best answer