+ Start a Discussion
Swamy P R NSwamy P R N 

restriction for user access by validation

HI Folks,

I have a scenario i.e, Whoever is created the record but that record users manager & system admin only edit the record based on Grade field. For this i implemented a validation, but its not working properly. So please suggest me.

AND(
OR(ISCHANGED( Grade_1__c ), ISCHANGED( Grade_2__c ), ISCHANGED( Grade_3__c )),
OR( $User.Id=$User.ManagerId )
)

Highly appreciated!!

Best Answer chosen by Swamy P R N
Vatsal KothariVatsal Kothari
Hi Swamy,

You can use below updated formula:
IF(OR(ISCHANGED( QnxSPM__End_Date__c ) ,ISCHANGED( QnxSPM__Start_Date__c )),IF(AND($User.Id <> Owner.ManagerId, $User.ProfileId <> 'SystemAdministratorProfileID'), true,false),false)
Replace SystemAdministratorProfileID with Appropriate ID of System Admin Profile.

If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal

All Answers

Swamy P R NSwamy P R N
I was able to compare with system admin profile but am not able to compare with record owner managerid.

Only Record " Owners Manager " and " System admin " people can edit the record.

AND(
OR( ISCHANGED( QnxSPM__End_Date__c ) ,
    ISCHANGED( QnxSPM__Start_Date__c )          
),
OR( $User.Id <> $User.ManagerId ,
    $Profile.Name  <> "System Administrator"
)
)

Can anyone suggest me..
Pavan DavePavan Dave
Getting record owner's manager id in validation rule is not possible, I guess.

You may need to go for apex validation error.
Swamy P R NSwamy P R N
Its possible by using " $User.ManagerId " . But how can i compare with record owner Manager.
Do you have any idea on this.
Vatsal KothariVatsal Kothari
Hi Swamy,

You can use below formula:
IF(ISCHANGED(TextField__c),IF(AND($User.Id <> Owner.ManagerId, $User.ProfileId <> 'SystemAdministratorProfileID'), true,false),false)
Replace SystemAdministratorProfileID with Appropriate ID of System Admin Profile.

If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal
Vatsal KothariVatsal Kothari
Hi Swamy,

You can use below updated formula:
IF(OR(ISCHANGED( QnxSPM__End_Date__c ) ,ISCHANGED( QnxSPM__Start_Date__c )),IF(AND($User.Id <> Owner.ManagerId, $User.ProfileId <> 'SystemAdministratorProfileID'), true,false),false)
Replace SystemAdministratorProfileID with Appropriate ID of System Admin Profile.

If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal
This was selected as the best answer