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
anurajanuraj 

FIELD_CUSTOM_VALIDATION_EXCEPTION

Hi

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 

Thanks

Anuraj

 

crop1645crop1645

anuraj:

 

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. :)