You need to sign in to do that
Don't have an account?

How to close a Case with apex
Hi all.
I am trying to test a trigger that checks whether a Case is closed or not, but I can't close a Case in order to test my trigger.
I am doing the following in my test code.
Case parent = new Case();
Database.insert(parent);
Case child = new Case();
child.ParentId = parent.Id;
child.Status = 'Fechado'; // This label is set up to true in isClosed field in CaseStatus
Database.inset(child);
System.debug(child.Status); // It outputs Fechado
System.debug(child.isClosed); // It outputs false
Can someone help me? Sorry for my poor English.
After you insert or update a record, you have to query the values back from the database. Only the ID value is updated in the memory reference for that record.
All Answers
After you insert or update a record, you have to query the values back from the database. Only the ID value is updated in the memory reference for that record.
Thanks fellow.
You are right.
Only the ID value is updated in the memory reference for that record.
I didn't know that.
Thanks again.