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

dates comparison

Hi All,

Can someone suggest me how to write trigger for the below scenario?
I have one Account, which can have many contacts. 
there are custom fields on contact object 1.Event date(date) 2. Active(Checkbox).
so whenever I'm adding a contact to the account, I need to make it active, here i have one condition if have multiple contacts for the same account i need to check the event date field on contact and if there two contact events with the same year i need to make one contact as active and another as inactive.
Eg: Account A got 2 Contacts, all are active
-cont1 Event date is 01/01/2016
-cont2 event date is 01/01/2017
If a new contact is created (cont3) with event date 01/02/2017 
- cont1  will remain active
- cont2  will be inactivated
- cont3 will become active 
Hope my question is clear.
Thanks in advance.

Tejender Mohan 9Tejender Mohan 9
Have you tried to use "Visual Flow" or "ProcessBuilder"  ?