
11 件の回答

Please try code like this:Opportunity opportunity_Obj = new Opportunity(IsPrivate = false, Name = 'Name144',Account_Record_Type__c = 'Tenant', Property_Name_Text__c = 'ogcp', StageName = 'Exchanging Proposals', CloseDate = Date.today(), Budget_Confirmed__c = false, Discovery_Completed__c = false, ROI_Analysis_Completed__c = false, Additional_Approval_Required__c = false, Deal_Submitted_for_Approval__c = false, Deal_Type__c = 'New Lease', Leasing_Property_Lead__c = user_id, Property__c = propertyObj_Id, Has_Options__c = false, Highest_Active_Deal__c = false); Insert opportunity_Obj; opportunity opp=[select id,StageName from Opportunity where id=:opportunity_Obj.Id]; opp.StageName='Fully Executed Lease'; update opp;Test.startTest();OpportunityFieldHistory coh = new OpportunityFieldHistory(OpportunityId = opp.id, Field = 'StageName'); insert coh; String Query='SELECT id,OpportunityId,CreatedDate,oldValue,NewValue,Field from OpportunityFieldHistory'; ESRT_SendNotificationsOrEmailsBatch obj=new ESRT_SendNotificationsOrEmailsBatch(Query); DataBase.executeBatch(obj,100);Test.stopTest();