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
sfdc2705sfdc2705 

I want to write a validation rule to achieve this.

Opportunity owner is a Salesforce user and that Salesforce user must have an 'Super User - xxx' user profile on their user record.

 

Please help me with the code to achieve this.

 

Thx

 

apkv1234apkv1234

Can you please be a bit more clear on the requirement and let me know what exactly needs to be achieved.

 

Regards,

APKV

Marko LamotMarko Lamot

you may use $User.ProfileId  in your validation rule to check whether particular profile is editing opportunity or not.

Shannon HaleShannon Hale

Effective with the Summer '13 release, you should be able to write a validation rule like this:

 

Owner.Profile.Name != "Super User - xxx"

However, this will use two of your cross-object references (out of the limit of 10), so if you are dealing only with one profile and you don't have to worry about profile IDs changing between sandbox and production, you might want to use Owner.ProfileId instead:

 

Owner.ProfileId != "00eD0000000zcY4" /* Substitute your own profile ID for this one */

This still requires one cross-object referenct to Owner but ProfileId doesn't require one.

 

If the profile name is actually variable (say you have multiple profiles that start with "Super User" but the "xxx" part changes), you could do something like this instead:

 

NOT( BEGINS( Owner.Profile.Name, "Super User" ) )

 In this case you need to use Owner.Profile.Name because you need to actually parse the text in the profile name.

Marko LamotMarko Lamot

Shale, that's very cool :)

Shannon HaleShannon Hale

Thank you, Marko! I try :-)