lundi 21 août 2017

recalculateFormulas() is not working properly

I am using recalculateFormulas() in apex but it is setting the formula fields to 0 not calculating the values. This is my code I am not using insert because I need to write test method using Mock.

Service_Report__c testReport = 
    TWGTestFactory.createServiceReportByCaseId(testCase.Id );
    testReport.recalculateFormulas();
    testReport.Id = TWGTestFactory.getFakeId(Service_Report__c.sObjectType);
    testReport.Visit__c = testVisit.Id;
    testReport.Labour__c = 200;
    testReport.Transport__c = 100;
    testReport.Add_Excess_Amount__c = true;
    testReport.Excess_Deductible_Amount__c = 10;

And even I tried by writing testReport.recalculateFormulas() at the end but then it is throwing an exception of Data Not Found.Please help me....

Aucun commentaire:

Enregistrer un commentaire