Skip to main content
edited tags
Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

List contracts = new List {
new Contract(
AccountId = DB.getAccountByNUID('800000004').Id,
Academic_Year__c = '2020-2022',
Is_Canceled__c = false,
StartDate = Date.newInstance(2021, 10, 10),
RecordTypeId = CPSContractUtil.getRecordTypeId('Faculty Teaching Assignment'),
//Course_Section_ID__c = getCourseSectionByName('202215-80003').id,
Type__c = 'Primary',
Status = 'Draft'
)

List<Contract> contracts = };new List<Contract> {  
    new Contract(  
              AccountId = DB.getAccountByNUID('800000004').Id,   
              Academic_Year__c = '2020-2022',  
              Is_Canceled__c = false,   
              StartDate = Date.newInstance(2021, 10, 10),  
              RecordTypeId = CPSContractUtil.getRecordTypeId('Faculty Teaching Assignment'),  
              //Course_Section_ID__c = getCourseSectionByName('202215-80003').id,  
              Type__c = 'Primary',  
              Status = 'Draft'  
    )      
};  
insert contracts;  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account does not have valid appointment for Class Academic Year.: [] this error is coming.

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account does not have valid appointment for Class Academic Year.: [] this error is coming.

List contracts = new List {
new Contract(
AccountId = DB.getAccountByNUID('800000004').Id,
Academic_Year__c = '2020-2022',
Is_Canceled__c = false,
StartDate = Date.newInstance(2021, 10, 10),
RecordTypeId = CPSContractUtil.getRecordTypeId('Faculty Teaching Assignment'),
//Course_Section_ID__c = getCourseSectionByName('202215-80003').id,
Type__c = 'Primary',
Status = 'Draft'
)

   };  
   insert contracts;  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account does not have valid appointment for Class Academic Year.: [] this error is coming.

List<Contract> contracts = new List<Contract> {  
    new Contract(  
              AccountId = DB.getAccountByNUID('800000004').Id,   
              Academic_Year__c = '2020-2022',  
              Is_Canceled__c = false,   
              StartDate = Date.newInstance(2021, 10, 10),  
              RecordTypeId = CPSContractUtil.getRecordTypeId('Faculty Teaching Assignment'),  
              //Course_Section_ID__c = getCourseSectionByName('202215-80003').id,  
              Type__c = 'Primary',  
              Status = 'Draft'  
    )      
};  
insert contracts;  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account does not have valid appointment for Class Academic Year.: [] this error is coming.

Source Link
Anzar
  • 954
  • 5
  • 24
  • 53

My method is failing in test

List contracts = new List {
new Contract(
AccountId = DB.getAccountByNUID('800000004').Id,
Academic_Year__c = '2020-2022',
Is_Canceled__c = false,
StartDate = Date.newInstance(2021, 10, 10),
RecordTypeId = CPSContractUtil.getRecordTypeId('Faculty Teaching Assignment'),
//Course_Section_ID__c = getCourseSectionByName('202215-80003').id,
Type__c = 'Primary',
Status = 'Draft'
)

   };  
   insert contracts;  

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account does not have valid appointment for Class Academic Year.: [] this error is coming.