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
akshay desai 9akshay desai 9 

test class field is not writeable error

Order order1=new Order();
        order1.AccountId=ac.Id;
        order1.EndDate=Date.newInstance(2019,07,25);
        order1.Pricebook2Id=priceBookS.Id;
        order1.EffectiveDate=Date.newInstance(2019,07,16);
        order1.Status='In';
         order1.TotalAmount=1;
        order1.totaltransaction=1;
        //order1.Status='In';
        insert order1;

my test class is this I have validation rule that is totalamount = totaltransaction so when i am running the test it is failing because of validation rule 

But totalAmount field is not writeable and totaltransaction is rollup field 

how can I insert the TotalAmount field in testclass
GarryPGarryP

you may have to insert the related line item record with Amount field populated which will eventually populate the totalAmount on order.