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

Stamping most recent activity on custom field

I want to create a custom field where the most recent activity could be stamped there, I would like this on the Account level.  

This way I can run an Account report and see the most recent activities as well.

Could someone help me creating a trigger for this?
Dario BakDario Bak
Here is a code that will do that for tasks in Opportunity. I challenge you to start with this and port it to Account.
trigger updateOpportunityFromTask on Task (after insert, after update) {
    map<id,opportunity> opps = new map<id,opportunity>();
    for(task {
        if(record.whatid != null && record.whatid.getsobjecttype() == opportunity.sobjecttype) {
            opps.put(record.whatid, new opportunity(id=record.whatid,       
    update opps.values();