• jstamers1.3929268330885625E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi all,

I have a trigger which creates a new record under the object Subject__c when a certain criteria is met in another object Volunteer__c. The actual data contained within the Subject recrod will be identical to the Volunteer record. This is currently working but I also want the new subject record to become a child of another object called Trial__c. Does anyone have a suggestion on how to do this? Here is what my trigger currently looks like:

Trigger copyVolunteertoSubject on Volunteer__c(after insert, after update)
{
     List<Subject__c> sub=new List<Subject__c>();
     for(Volunteer__c v : Trigger.new)
     {
           if(v.Volunteer_Status__c == 'Screening Complete')
           {
                   Subject__c s=new Subject__c();
                   s.First_Name__c=v.First_Name__c;
                   s.Age__c=v.Age__c;
                   s.BMI__c=v.BMI__c;
                   s.City__c=v.City__c;
                   s.Country__c=v.Country__c;
                   s.Date_of_Birth__c=v.Date_of_Birth__c;
                   s.Email_Address__c=v.Email_Address__c;
                   s.Gender__c=v.Gender__c;
                   s.Height__c=v.Height__c;
                   s.Last_Name__c=v.Last_Name__c;
                   s.Phone_Number__c=v.Phone_Number__c;
                   s.Postal_code__c=v.Postal_code__c;
                   s.Province__c=v.Province__c;
                   s.Street_Address__c=v.Street_Address__c;
                   s.Weight__c=v.Weight__c;
                   s.Name=v.Name;
                   //add other fields of subject here and add volunteer values in that.
                
                   sub.add(s);
            }
            if(sub.size()>0)
            insert sub;
     }
}