[SalesForce] $profile.name in validation rule not working

Set up a validation rule like:

AND(
  ISPICKVAL(PRIORVALUE(StageName), 'Closed Won'),
  ($Profile.Name <> 'System Administrator')
)

After an opportunity is closed won, only system administrators can edit the record. But $profile.name seems to be not working.

Requirement: Once a record is saved as 'Closed Won'. Next time any user whose profile is not system administrator should not be able to edit the record

Thanks.

Best Answer

The reason why $Profile.Name <> 'System Administrator' is not working might be due to the default language set at Company level. If it's different than English then all standard profile names are translated. If your organization uses language different than English then there is no longer a profile called 'System Administrator' - it is translated to the language used. This applies also to validation rules, workflows, etc. Is that your case?

In my opinion there are many workarounds but I don't know a perfect solution. I can think of following:

  • hardcoding the Profile Id
  • using clone of System Administrator (custom profile which is not translated)
  • or using a custom label with profile name in correct language (or with translations)
Related Topic