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
SambitNayakSambitNayak 

System.DmlException (FIELD_CUSTOM_VALIDATION_EXCEPTION)

Hi,

I'm writing a test class to check that I can change the status field of one of my objects successfully.
When I anonymously create the record with status ='New' and then change the status='Scheduled', I'm not facing any issues.

But when I'm using the exact same code in a Test Class, I'm facing the following issue:

 

EXCEPTION_THROWN [34]|System.DmlException: Update failed. First exception on row 0 with id 08p76000000sxxxxx; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot change status from New to Scheduled: [Status]


Any advice is really appreciated. Thanks

Best Answer chosen by SambitNayak
SubratSubrat (Salesforce Developers) 
Hello Sambit ,

Can you try using IsTest(SeeAllData=False) Annotation and check again .

Thank you.

All Answers

SambitNayakSambitNayak
Just FYI,
I dont have any Validation Rule or Before Trigger logic on this.
SubratSubrat (Salesforce Developers) 
Hello Sambit ,

Can you try using IsTest(SeeAllData=False) Annotation and check again .

Thank you.
This was selected as the best answer
SambitNayakSambitNayak

Hi @Subrat. Thanks for your help. 

However, It's not helping :(

SubratSubrat (Salesforce Developers) 
Hi sambit ,

Can you share your class and test class both .

Thank you.
SambitNayakSambitNayak

Hi Subrat,

The actual annotation is @isTest(SeeAllData=true)

 

Thanks so much. I chose your answer as best.