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
shifali sharma 11shifali sharma 11 

closed Date is not writable

Hi all,
I have one batch class with scenario
 'SELECT ID from LiveChatTranscript where caseid in (SELECT ID from Case where Closeddate >: caseclosedate and Closeddate
i am try to delete all the livecases transcipt which are between 6 and 7 days before ,but i am facing issue in testclass because closeddate is not writable so  can you please help me how can i test this scenario i tried JSON string not getting output.
sowmya Inturi 9sowmya Inturi 9
Hi,
Update the Case status to 'closed' after inserting the case. It will automatically populate ClosedDate.

For Example:

@isTest private class CaseCloseTest {
static testMethod void myUnitTest() {
Case c = new Case();
c.Status='New';
c.subject='Test',
insert c;
try {
c.Status='Closed';
update c;
}
Catch(Exception ee) {}
}
}

Thanks,
Sowmya