I have after update trigger on Agent work and that fires when agent is declines the case in the omni channel by choosing the declining reason = 'Closed'. I have done development and everything is working fine.
When am writing test class for this trigger unable to create test data as below.
AgentWork awork = new AgentWork(); awork.WorkItemId = caseObj.Id; awork.ServiceChannelId = Label.Case_Service_Channel_Id; awork.UserId = Userinfo.getUserId(); awork.DeclineReason = 'Closed'; insert awork; update awork;
Saying Field is not writeable:
Any idea how could i cover my apex class by writing the proper test data?