I am trying to remove the section of the apex class that references the close date but I am getting an error that record creation failed when selecting my button. Do you have any suggestions?
{public class New_Clinical_Opp_Controller { @AuraEnabled public static string createClinicalOpportunity(Id AccountrecId) { String returnValue = ''; List oppList = new List(); Opportunity oppObject = new Opportunity();
oppObject.Name = 'Do Not Delete';
oppObject.AccountId = AccountrecId;
oppObject.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Clinical').getRecordTypeId();
oppObject.StageName = 'Qualification';
Date closeDate = system.today();
closeDate = closeDate.addMonths(6);
oppObject.CloseDate = closeDate;
oppList.add(oppObject);
if(!oppList.isEmpty())
{
Database.SaveResult[] a = Database.insert(oppList, false);
if(a[0].isSuccess())
{
returnValue = oppList[0].id;
}
else
{
returnValue = 'failure';
}
}
return returnValue;
}
}
{}
tool to format it. Screenshots of code are unfriendly to those on mobile and using assistive technology like screen readers.