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
@ M  Coder@ M Coder 

Trigger Sorting and populating the Dates #Urgent

Hello All , 
How to write trigger ??

Under Account we have open activities, where we create Task and events. 
Scenario: i need to take Duedate value which is comming nearby from the below ones into a customfield Named NearbyDate__c. 

I need to write Trigger logic insuch away that for N number of Activities if i either Add or delete the activities it should sort and  gimme the result. 

for example: 

My output  should be from below example
NearbyDate__c = 9/15/2020 

User-added image

can anyone show some insights on this please. 

@thanks in adv
ANUTEJANUTEJ (Salesforce Developers) 
Hi there,

Could you please mention the above scenario with an example so that we can check further and respond.

Looking forward for your response.

Regards,
Anutej
@ M  Coder@ M Coder
Hello ANUTEJ , 

Sorry for late response 
Scenario : i have a field on Account ie NearbyDate__c

so for the account lets us say i have below open activities 
snip

so in the above let say todays date is oct 20 , i need to take the nearby day to today ie 28/10/2020 out of the above 3 open activities and update the value as 
Account.NearbyDate__c = 28/10/2020

Thanks in advance.