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
jeff.barnettjeff.barnett 

Determining user's profile within Trigger

 

Being new to APEX coding I’m struggling with how to determine the user’s profile in a trigger.  I know in VisualForce pages there is $Profile.  Is there something similar to that in triggers?

 

Thanks

Jeff

SFAdmin5SFAdmin5

hey jeff.  there are several ways and it depends what you are trying to do.  something like

 

Owner.Profile.Name = 'System Administrator'

 

in a soql query might work

vishal@forcevishal@force

Yes, there are various ways of knowing the current user's profile.

 

Simplest , according to me, would be to get the user's profile Id using userinfo.getProfileId() and then query the related profile based on the Id.