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
Sabrina Oliveira 3Sabrina Oliveira 3 

Profiles and fields exceptions in a validation rule

When my account is active, only System Administrators and Compliance profiles can edit it.
The problem is that Controller needs to be able to edit some fields (Letters, Charge and Statement), but not all of them as the System Administrator and Compliance.
I'm stucked on this. Can you help me?

Validation rule:
(NOT(
$Profile.Name = 'System Administrator' ||
CONTAINS($Profile.Name, 'Compliance')
)
&&
ISPICKVAL(Status__c,'Active')
&& LastModifiedDate <> NOW()
&& not(ISCHANGED(Active__c)))
||
(NOT($Profile.Name = 'Controller') 
&&
ISPICKVAL(Status__c,'Active')
&& LastModifiedDate <> NOW()
&& not(ISCHANGED(Letters__c))
&& not(ISCHANGED(Charge__c))
&& not(ISCHANGED(Statement__c)))

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sabrina,

 Can you confirm of my understanding is correct.

only system admin and compliance profiles can edit the active accounts. Apart from this some fields can be edited by Controller profile. Inactive accounts can be edited for all profiles right?

Is this the requirement.

Thanks,
 
Sabrina Oliveira 3Sabrina Oliveira 3
Hi Sai Praveen,

Yeah, exactly it!
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sabrina,

Can you please check if this formula works.
 
IF( ISPICKVAL( Status__c ,'True') , IF(OR( $Profile.Name ='System Administrator', CONTAINS($Profile.Name, 'Compliance')), False ,IF( AND($Profile.Name ='Controller',OR( ISCHANGED( Charge__c), ISCHANGED( Letters__c ) , ISCHANGED( Statement__c ) ))
,FALSE,TRUE)),false)

If this solution helps, Please mark it as best answer.

Thanks,
 
Sabrina Oliveira 3Sabrina Oliveira 3
Hi Sai Praveen,
Thaks for your answer.
I've tried, but with this solution Controller is able to edit all the fields and not only Letters, Statement and Charge :(
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sabrina,

Is the Account status is true in the above scenerio?

Thanks,
Sabrina Oliveira 3Sabrina Oliveira 3
Yes, it is! The account is active
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sabrina,

I will verify in my org and confirm you .

Thanks,
Sai PraveenSai Praveen (Salesforce Developers) 
HI Sabrina,

I have verified in my org. I see they were only able to edit the three mentioend fields of the profile is Controller. If they are editing any other fields they were getting validation if the account it active . 

Thanks,