• Annabelle Blackburn
  • NEWBIE
  • 20 Points
  • Member since 2015
  • Sales Executive
  • Emoderation

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 3
    Replies
Hi there,
I have a custom object called Whitepapers (WP), and its child custom object called Whitepaper Downloads (WPD). On my WPD I have a field called Date Downloaded. I would like to add a field to WP that displays the latest WPD Date Downloaded.
I believe I need an apex trigger for this because formulas don't reach up that way on custom objects. Any ideas on what that trigger would look like?
Thanks for your help!
Annabelle
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!

Thanks!
Hi there,

I'm looking to create a field that automatically populates with the Latest Activity Subject. When pulling reports I need to be able to see the latest activity subject and in the out-of-the-box Salesforce you only have access to Latest Activity Date.

From looking around it seems the only way to do this is to create an apex trigger that will populate a Latest Activity Subject field that I create. I'm fairly new to Salesforce and would really appreciate some A-Z guidance on how to best create this.

Thanks!
Hi there,
I have a custom object called Whitepapers (WP), and its child custom object called Whitepaper Downloads (WPD). On my WPD I have a field called Date Downloaded. I would like to add a field to WP that displays the latest WPD Date Downloaded.
I believe I need an apex trigger for this because formulas don't reach up that way on custom objects. Any ideas on what that trigger would look like?
Thanks for your help!
Annabelle
Hi there,

I'm looking to create a field that automatically populates with the Latest Activity Subject. When pulling reports I need to be able to see the latest activity subject and in the out-of-the-box Salesforce you only have access to Latest Activity Date.

From looking around it seems the only way to do this is to create an apex trigger that will populate a Latest Activity Subject field that I create. I'm fairly new to Salesforce and would really appreciate some A-Z guidance on how to best create this.

Thanks!
This is the first time I have used an Apex trigger and I am struggling to get it to work. I took the code used from here https://developer.salesforce.com/forums?id=906F00000008yXUIAY. And then adjusted it so it fit for leads and the names of fields I currently have in my for my leads. I am not getting any errors now, but the code does not seem to be doing anything and is active. The items I changed were changing any opportunity or opp to lead, whatid to id to get rid of errors, and the name of fields. What i want to have happen is the subject of activities to become its own field, and only display the last activity subject. The Last_Activity_Date_c field is a field I created that uses a simple formula that pulls the last activity date through. If anyone has any insight it would be greatly appreciated. Here is my code for reference:

trigger NextTastInfo on Lead (after insert, after update) {
          

  if(Trigger.new.size() == 1 ) {

    Lead tk = Trigger.New[0];
    String str = tk.id;
    if(str != null && str.substring(0,3)== '006')
    {

         Lead lead = [select OwnerId,Last_Activity_Subject__c,Last_Activity_Date__c from Lead where Id = :tk.id ];

        List<Task> tskMin = [Select ActivityDate,Subject From Task where id=:tk.id and  what.type = 'Lead' and isClosed = false order By ActivityDate limit 1];

        if (tskMin.size()>0) {
                lead.Next_Step_Date__c=tskMin[0].ActivityDate;
                lead.Last_Activity_Subject__c=tskMin[0].Subject;
        }
        else {
                lead.Next_Step_Date__c=null;      
                lead.Last_Activity_Subject__c='';
        }
        update lead;
    }
}
}