• chandan kumar 99
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi Gurus, 

I have a trigger on Task object and I am trying to before insert and update a field Task object. I am getting following error message:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger WeekendTasks caused an unexpected exception, contact your administrator: WeekendTasks: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T7F00000G5ulOUAR; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T7F00000G5ulO) is currently in trigger WeekendTasks, therefore it cannot recursively update itself: []: Trigger.WeekendTasks: line 15, column 1

Here is my trigger
trigger WeekendTasks  on Task (before insert,Before update) {
    list<Task> Tasweek =new List<Task>();
           for(Task tweek:Trigger.new){
                if(tweek.Subject != null) {
                   Date origin = Date.newInstance(1900,1,6);
                   Date due = tweek.ActivityDate;
                   Integer x = origin.daysBetween(due);
                   Integer day = Math.mod(x,7);
                   if (day < 2 ) {
                     Task tas = new Task (Id = tweek.Id,ActivityDate = (tweek.ActivityDate + 2));
                     Tasweek.add(tas);
                   }
                 }
           }
          update Tasweek;  
}
Hi everyone 
my question is 

How Many way to create multi-select picklist. Please solve


Thanks
  • We have standard "Contact" object in SFDC.
  • You have to add one Field in Contact Object that is "Total Family Members" type is Number(2,0):
  • Let Account be the Family. So if there are 5 Contacts belongs to same account, that means these all 5 belongs to same family.
What you have to do:                 
  • Create a trigger on Contact to calculate "Family Members Count".
    • Create one Account: Create New Contact as a child for it. Then Contact's "Total Family Member" will have value 1.
    • Create another Contact for the same Account then Both Contact should have value 2 for "Total Family Member Field".
    • if someone changes contact's family like : changing account lookup value for a contact, then Both family will reflect. Because one family member is removed from one family and added to new Family. values should be updated: 
      •  All Contact's of Older Family should now have the "Total Family Member" value decreased by1. 
      • And for new family all Contact's "Total Family Member" will have value increased by1.