• Aarya Tiwary 12
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

Hopefully someone can help me out here. I have written the following code:



public with sharing class insertPatientProtocolSchedule {
  //added an instance varaible for the standard controller
     private ApexPages.StandardController controller {get; set;}
     // initialize the controller
     public insertPatientProtocolSchedule(ApexPages.StandardController controller) {
        //initialize the stanrdard controller
        this.controller = controller;
        //Define Master Objects
  Protocol_Arm__c pa = new Protocol_Arm__c();
  Patient_Protocol_Record__c ppr = new Patient_Protocol_Record__c();
  //Create a list of objects.  Populate it with a query to the database.
  list<Protocol_Arm_Activities__c> pactList = [SELECT Name FROM Protocol_Arm_Activities__c WHERE Protocol_Arm__r.Id = :ppr.Protocol_Arm__r.Id];
//Cycle through the list, and for each object create a new one, the only difference being the MasterId
  list<Protocol_Arm_Activities__c> NewList = new list<Protocol_Arm_Activities__c>();
  for (Protocol_Arm_Activities__c paa : pactList) {
     Patient_Protocol_Activity__c ppa = new Patient_Protocol_Activity__c();
     ppa.Name = paa.Name;
     ppa.Patient_Protocol_Record__c = ppr.Id;
     NewList.add(ppa); // Error Line
// insert new records
  insert NewList;
    // method called from the VF's action attribute to clone the schedule
    public PageReference addSchedule() {
And I am getting the following Error In Eclipse on the line I have marked with //Error Line:
Save error: Incompatible element type SOBJECT:Patient_Protocol_Activity__c for collection of SOBJECT:Protocol_Arm_Activities__c
I am not seeing any issues.
Both Patient_Protocol_Activity__c and Protocol_Arm_Activities__c are the Detail in a Master-Detail relationship.
Thank you for any help you can provide.