List<Profile> profiles = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1]; String MyProflieName = profiles[0].Name;
Alternate, if you don't want to use SOQL query
Create a formula field such as 'CurrentUserProfile' on the object with formula: $UserProfile.Name In the trigger, refer to the field: System.debug('Current User Profile: ' + record.CurrentUserProfile__c);
Actually, i'm looking for profile name of any user by their id or username not just the current user. Activities are added y multiple systems and i cant reply on current user to be of the right profile.
That should point you in the right direction
All Answers
In your trigger do a SOQL query:
List<Profile> profiles = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1];
String MyProflieName = profiles[0].Name;
Alternate, if you don't want to use SOQL query
Create a formula field such as 'CurrentUserProfile' on the object with formula: $UserProfile.Name
In the trigger, refer to the field:
System.debug('Current User Profile: ' + record.CurrentUserProfile__c);
Regards
Andrew
That should point you in the right direction