You need to sign in to do that
Don't have an account?
stollmeyera
Trigger to grab Owner Profile ID
I am a begginer at this and wrote a simple trigger to grab the Profile ID of a Lead owner and store it under a custom field. It is below:
trigger ProfileIDCopy on Lead (before Insert, before Update) { for(Lead x : Trigger.New){ // Confirm owner is not a Queue then map Profile ID to custom field if( ((String)x.OwnerID).substring(0,3) == '005' ){ x.Owner_Profile_ID__c = x.Owner.Profile.ID; } else{ // If not above, mark as queue x.Owner_Profile_ID__c = 'Queue'; } } }
The trigger saves, but it does not actually work when I test it. The Owner_Profile__ID does not get populated. My guess is that "Owner.Profile.ID" is not a proper call, but the fact that it saves with no error is not reassuring. Could someone please offer some guidance? Thanks in advance!
I think you want
for getting the Profile Ids, it will be better if you use Userinfo Methods. Try
userinfo.getprofileId
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm
Did you find a solution for this?
I think the only option is to query the User table and then do a vlookup type call to grab the Profile ID for the referenced Owner ID. Now I just have to figure out how to actually do this in APEX :)
Any other suggestions would be welcome.
Should be something like:
If you want the name of the profile, you'd need to query profile to get it.