function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfg1sfg1 

Need help in creating test data for master and child object record

I have Amendment(master) and Amendment_Role__c(child). IN my test class i am trying to create test data for  Amendment & Amendment_Role__c. I have created test data for Amendment using test factory, i am getting error while creating data for Amendment_Role__c. please guide me.
//Insert Amendment Record
  Amendment__c amendmentRecord=PRLDE_DataFactory_Test_Utility.insertAmendment(false,contactRecord.Id,opportunityAssistanceRecord.Id,opportunityRecord.Id,amendmentRecordType);
             //Insert File record
            Files__c fileRecord=PRLDE_DataFactory_Test_Utility.insertAmendmentsFiles(amendmentRecord.Id,'Amendment Documents',System.today(),'Amendments');    
          
  //Insert Amendment_role__c reocord
   Amendment_Role__c ARC = new Amendment_Role__c();   
   ARC.id = 'amendmentRecord.id';
   ARC.Name = 'testname';
   ARC.User__c = 'TESTuser';
   ARC.Role_Name__c = 'testrle'; 
   ARC.amendmentRecord = 'TEST'; 
   Insert ARC; 
Best Answer chosen by sfg1
Lokesh KumarLokesh Kumar
HI Dhana,

Try by removing single quotes in  ARC.id = 'amendmentRecord.id'; this is a variable so doesn't require quotes.

Thanks !

All Answers

Lokesh KumarLokesh Kumar
HI Dhana,

Try by removing single quotes in  ARC.id = 'amendmentRecord.id'; this is a variable so doesn't require quotes.

Thanks !
This was selected as the best answer
sfg1sfg1
thankyou Lokesh