+ Start a Discussion
Annabelle BlackburnAnnabelle Blackburn 

Apex trigger for cross object data in Activities

Hi there,

My Users are sorted by a custom field called 'Pod', which basically sorts them into teams. On standard objects such as Accounts and Contacts, I have been able to add a custom formula that populates a Related Pod field according to the Owner's Pod, so if John Smith is the Account Owner for ABC, and John Smith belongs to Pod Alpha, then the Related Pod field on the ABC Account will show Pod Alpha. This allows me to sort reports via Pods which is super convenient.

I would like to be able to work this way with Activities, but unfortunately it seems the formula approach won't work since Activities don't allow cross object look ups. According to Salesforce support, my best approach would be to create an Apex trigger that would pull in the Assigned To User's Pod into a field on each Activity.

I'm still fairly new so any suggestions would be great!

Best Answer chosen by Annabelle Blackburn
You can use the formula field in activity object to get the activity owner field information. Try the below formula field in activity object custom fields to get the activity owner user name
Replace Username with your custom field API name