+ Start a Discussion



I am writing a test class but i am getting this error 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION,


but when i enetr value to

p.Forecastable__c = 'yes'; 

then i have another

error Field is not writeable: 

it is a formula filed


Please help me to solve this 







1. You can't use APEX to set formula fields

2. It is hard to say why you are getting the error given the limited detail you provide - but, if the validation rule depends on the formula field being a specific value, then you need to be sure that all the inputs to that formula field are included in your DML insert (or update) statement

Nilesh ManeNilesh Mane

See on which fields your formula field is depending.

Set the values for those fields only.

You cant set value for Formula field in test class.


Hope this will help u. :)