• S Shah
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello,
I could use some help on my trigger. I am trying to copy some fields from two standard objetcs into one custom object (dataTable__c). I am trying to copy several fields from Opportunities as well as some fields from Tasks (if the task is related to opportunity) into my custom object. Tasks has a lookup realtionship to opportunities (related to = what). My custom object has a master detail relationship to opportunity (opporunityName1__c). 
I am new to apex and would really appreciate your help. I figured out one part of the equation but I am not sure how I would include a trigger that works on the second object. I don't want to have two seperate triggers working seperately .The end result should be that all the fields from both objects are in th same record. I am pretty sure I will need to use SOQL but I can't seem to find exactly what I need. Here is what I got so far. THANK YOU

Trigger AutoDT on Task (after insert,after update) {
List <DataTable__c> newdt = new List <DataTable__c> ();
for (Task t : Trigger.new) {
DataTable__c dts = new DataTable__c ();
dts.TaskSubject__c = t.subject;
dts.TaskStatus__c = t.status;
dts.TaskPriority__c = t.priority;
dts.TaskComments__c = t.Description;

dts.taskDateTaskAssigned__c = t.date_task_assigned__c;
dts.TaskDueDate__c = t.ActivityDate;

newdt.add (dts);
}
insert newdt;
}
  • April 09, 2015
  • Like
  • 0