You need to sign in to do that
Don't have an account?
MS123456
Need to update below fields from the Most Recent Event corresponding to a contact with type="consult" to the Contact objects in Salesforce.
Hi Team, I need help very very Urgent.....
Event is object and the Type='Consult'(picklist value)
If I have created the event automatically contact randomly assign to any contact.
But this contact most recently event field updated to this contact filed below field is on event object they are formula(text) and contact are text data type pls how to achieve this requirement .....
+++++++++++This is my code ++++++
trigger eventTriggerContact on Event (after insert, after update) { Set<Id> set_ContactId = new Set<Id>(); list<Contact> conList = new List<Contact>(); if(Trigger.isAfter && Trigger.isInsert) { for(Event e : Trigger.new) { if(e.whoId!=null && String.valueOf(e.whoId).startsWith('003')) { set_ContactId.add(e.whoId); } } Map<Id,Contact> conMap = new Map<Id,Contact>([Select Id,Department,StartDateTime__c,Start_Time__c,User_Attorney_Profile_Page__c,User_First_Name__c, User_Last_Name__c,User_Office_Google_Map_Link__c,User_Office_Phone__c, User_Office_Website__c from contact where Id IN:set_ContactId]); for(Event e : Trigger.new) { List<Event> e1 = new List<Event>([Select Id,whoId,StartDateTime,Start_Time__c from event where Id =:e.id]); system.debug('@@@@@@'+ e1); if(conMap!=null && conMap.containsKey(e1[0].whoId)) { conMap.get(e1[0].whoId).StartDateTime__c= e1[0].StartDateTime; conMap.get(e1[0].whoId).Start_Time__c= e1[0].Start_Time__c; conList.add(conMap.values()); } } system.debug('!!!!!!'+ conList); if(conList!=null && conList.size()>0) update conList; } }
As per my understanding you would want to update StartDate time and start time fields from contact. Bolow if the trigger for the same.
Let me know if this works.
Thanks,
Sukanya Banekar