• sakthi s 3
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have two stage ie task and event. My Custom field is "Latest Feedback" once customer create task means i fetch the feedback from task based on the "status" is completed and if the customer is reach event means same as above. My trigger is working fine but is not updated the event feedback it is show only task feedback.

This is my two trigger for update latest feedback on Account Page.

 trigger change_feedback on Task (after insert, after update) { 
        Set accountSet = new Set();
    
        List<Id> accIds = new List<Id>();    
        //variable to hold account id & task feedback
        Map<Id,String> accntValMap = new Map<Id,String>();
    
        //get task Account id & Feedback for tasks with Status "Completed"
        for(Task t : trigger.new){
            if(t.Status == 'Completed') {
                accntValMap.put(t.whatId,t.FEEDBACK__C); 
            }    
        }
    
        //query the accounts that we need to update
        List<Account> acctsToUpdate = [Select Id from Account where id in :accntValMap.keySet()];
    
        //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
            acc.Feedback__c = accntValMap.get(acc.Id);
        }
    
        //update the accounts back to database
        update acctsToUpdate;
    }

An After Insert trigger on Feedback that writes back to Event, and an After Update trigger on Feedback that waits for a related Latest Feedback to be created.

    trigger change_feedbackOnEvent on Event  (after insert, after update)  {
         Set<String> accountSet = new Set<String>();
         
         List<Event> events = [select Id,Whatid,FEEDBACK__C from Event where
         id in :trigger.newMap.keySet()];
         List<string> accIds = new List<string>();    
         //variable to hold account id & task feedback
         Map<Id,String> accntValMap = new Map<Id,String>();
         
         //get task Account id & Feedback for tasks with Status "Comnpleted"
         for(Event e : trigger.new){
            if(e.Feedback != '') {
              accIds.add(e.whatId);
            accntValMap.put(e.whatId,e.FEEDBACK__C); 
            }    
         }
         
          //query the accounts that we need to update
         List<Account> acctsToUpdate = [Select Id from Account where id in
         :accntValMap.keySet()];
         
         //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
         acc.Feedback__c = accntValMap.get(acc.Id);
        }
      
        //update the accounts back to database
        update acctsToUpdate;
    }

Both triggers are working fine but after created event that showing the task feedback in latest feedback field(custom field). I want the latest feedback of event.

I have two stage ie task and event. My Custom field is "Latest Feedback" once customer create task means i fetch the feedback from task based on the "status" is completed and if the customer is reach event means same as above. My trigger is working fine but is not updated the event feedback it is show only task feedback.

This is my two trigger for update latest feedback on Account Page.

 trigger change_feedback on Task (after insert, after update) { 
        Set accountSet = new Set();
    
        List<Id> accIds = new List<Id>();    
        //variable to hold account id & task feedback
        Map<Id,String> accntValMap = new Map<Id,String>();
    
        //get task Account id & Feedback for tasks with Status "Completed"
        for(Task t : trigger.new){
            if(t.Status == 'Completed') {
                accntValMap.put(t.whatId,t.FEEDBACK__C); 
            }    
        }
    
        //query the accounts that we need to update
        List<Account> acctsToUpdate = [Select Id from Account where id in :accntValMap.keySet()];
    
        //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
            acc.Feedback__c = accntValMap.get(acc.Id);
        }
    
        //update the accounts back to database
        update acctsToUpdate;
    }

An After Insert trigger on Feedback that writes back to Event, and an After Update trigger on Feedback that waits for a related Latest Feedback to be created.

    trigger change_feedbackOnEvent on Event  (after insert, after update)  {
         Set<String> accountSet = new Set<String>();
         
         List<Event> events = [select Id,Whatid,FEEDBACK__C from Event where
         id in :trigger.newMap.keySet()];
         List<string> accIds = new List<string>();    
         //variable to hold account id & task feedback
         Map<Id,String> accntValMap = new Map<Id,String>();
         
         //get task Account id & Feedback for tasks with Status "Comnpleted"
         for(Event e : trigger.new){
            if(e.Feedback != '') {
              accIds.add(e.whatId);
            accntValMap.put(e.whatId,e.FEEDBACK__C); 
            }    
         }
         
          //query the accounts that we need to update
         List<Account> acctsToUpdate = [Select Id from Account where id in
         :accntValMap.keySet()];
         
         //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
         acc.Feedback__c = accntValMap.get(acc.Id);
        }
      
        //update the accounts back to database
        update acctsToUpdate;
    }

Both triggers are working fine but after created event that showing the task feedback in latest feedback field(custom field). I want the latest feedback of event.

 
I have two stage ie task and event. My Custom field is "Latest Feedback" once customer create task means i fetch the feedback from task based on the "status" is completed and if the customer is reach event means same as above. My trigger is working fine but is not updated the event feedback it is show only task feedback.

This is my two trigger for update latest feedback on Account Page.

 trigger change_feedback on Task (after insert, after update) { 
        Set accountSet = new Set();
    
        List<Id> accIds = new List<Id>();    
        //variable to hold account id & task feedback
        Map<Id,String> accntValMap = new Map<Id,String>();
    
        //get task Account id & Feedback for tasks with Status "Completed"
        for(Task t : trigger.new){
            if(t.Status == 'Completed') {
                accntValMap.put(t.whatId,t.FEEDBACK__C); 
            }    
        }
    
        //query the accounts that we need to update
        List<Account> acctsToUpdate = [Select Id from Account where id in :accntValMap.keySet()];
    
        //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
            acc.Feedback__c = accntValMap.get(acc.Id);
        }
    
        //update the accounts back to database
        update acctsToUpdate;
    }

An After Insert trigger on Feedback that writes back to Event, and an After Update trigger on Feedback that waits for a related Latest Feedback to be created.

    trigger change_feedbackOnEvent on Event  (after insert, after update)  {
         Set<String> accountSet = new Set<String>();
         
         List<Event> events = [select Id,Whatid,FEEDBACK__C from Event where
         id in :trigger.newMap.keySet()];
         List<string> accIds = new List<string>();    
         //variable to hold account id & task feedback
         Map<Id,String> accntValMap = new Map<Id,String>();
         
         //get task Account id & Feedback for tasks with Status "Comnpleted"
         for(Event e : trigger.new){
            if(e.Feedback != '') {
              accIds.add(e.whatId);
            accntValMap.put(e.whatId,e.FEEDBACK__C); 
            }    
         }
         
          //query the accounts that we need to update
         List<Account> acctsToUpdate = [Select Id from Account where id in
         :accntValMap.keySet()];
         
         //now use the map variable to update the account field
        for(Account acc : acctsToUpdate){
         acc.Feedback__c = accntValMap.get(acc.Id);
        }
      
        //update the accounts back to database
        update acctsToUpdate;
    }

Both triggers are working fine but after created event that showing the task feedback in latest feedback field(custom field). I want the latest feedback of event.