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
dinesh abcdinesh abc 

how to update a text area field in opportunity based on task event log

Hi i need to show in opportunity fiekd that will contain what are the changes done in task ,event,log call those data updated  in opportunity field text area.
Krishna SambarajuKrishna Sambaraju
You can build a trigger on the Task and Event objects and update the opportunity related to them.
trigger updateOpportunityDescription on Task (after update)
{
	Map<Id, Task> oppIdMap = new Map<Id, Task>();
	for (Task t : trigger.new)
	{
		Id relatedId = t.WhatId;
		if (relatedId.getSObjectType().getDescribe().getName() == 'Opportunity')
		{
			oppIdMap.put(relatedId, t);
		}
	}
	if (!oppIdMap.isEmpty())
    {
		List<Opportunity> opps = [select Id from Opportunity where Id IN :oppIdMap.keySet()];
		for (Opportunity opp : opps)
		{
			opp.Description = oppIdMap.get(opp.Id).Description;
		}
		update opps;
	}
}
You can build a similar trigger on the Event object. Hope this helps.
 
dinesh abcdinesh abc
How to write test class for above trigger