Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (13.1k points)

I have a test class but it is not working at some of the point. These are the steps were it fails.

System.assertEquals('',[SELECT ANN_Accepted_From_Queue__c FROM Case Where Id=:r.Id].ANN_Accepted_From_Queue__c, assertMsg);

system.debug('o.RecordTypeId '+o.RecordTypeId+ 'wmgRecordTypeId'+wmgRecordTypeId);

18:14:23:180 USER_DEBUG [720]|DEBUG|o.OwnerId == 00518000003xRhcAAE oldMap.get(o.Id).OwnerId ==00518000003xRhcAAE

Can anyone help me why this is failing?

1 Answer

0 votes
by (26.7k points)

Actually, this will not work as because you have an in-memory record, so only the record ID is sent back to your code and everything else like trigger code, formula fields etc. you will not see immediately. So, you need a query to see these fresh values you can try something like :

Case newCase = [SELECT OwnerId, ANN_Accepted_From_Queue__c FROM Case WHERE Id = :c.Id];

I hope this will help. 

Want to become a Salesforce Expert? join Salesforce Training now!

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...