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

Trigger not Working as expected

Posted on Apex board as well, kind of need help as soon as possible Please? :)




I have a trigger that is supposed to update the Contact of a case that is closed:


 trigger setLastSurveySentDate on Case (after insert) {
    Map<Id,Id> contactToCaseMap = new Map<Id,Id>();
    for(Case A :
    List<Contact> contactsToUpdate = new List<Contact>{};
    for (Contact con: [SELECT Id,Last_Survey_Sent_Date__c FROM Contact WHERE Id IN:  contactToCaseMap.keySet()]) {
        Id caId = contactToCaseMap.get(con.Id);
        Case ca = trigger.newMap.get(caId);
        if (ca.Status=='Closed' && con.Last_Survey_Sent_Date__c < ){
        else if (ca.Status=='Closed' && con.Last_Survey_Sent_Date__c == null ){

    if(contactsToUpdate != null && !contactsToUpdate.isEmpty())


I have a workflow that sends a survey, updates the case Last Survey Sent Date case field, and records a task that the survey was sent, as long as the Contact has not received a survey within the last 90 days:


OR( today() - DATEVALUE(Contact.Last_Survey_Sent_Date__c) >= 90,isBlank(Contact.Last_Survey_Sent_Date__c))


The trigger is updating the contact field, however, it is not using the date that has been updated on the case.


The date of  survey sent CASE = 09/03/2013 12:15 AM

The date of survey sent CONTACT = 09/02/2013 8:00 PM


The date of survey sent on the contact is always the same time and the date changes depending on the real time of day (e.g. tests performed prior to 12 AM showed a date of 09/02/2013 8:00 PM)


Just bumping up. Please help?


But... your problem is on the trigger execution or the workflow, i did not get that.