1

I am using Omnichannel for acceptance of the case. The requirement is that when an Agent accepts a case, the case status should be updated to 'In Review'.

I have created the trigger on the AgentWork object but the trigger is not changing the status of the case on acceptance

trigger Omni_Work_Status on AgentWork ( after insert) {
  AgentWork aw = Trigger.New[0];
Case cs = new Case();
if(aw.AcceptDateTime != null){
    cs.Status = 'In Review';
}
}

Can you check this trigger, And let me know where I am getting wrong. Any suggestion would be appreciated.

0

Hi i have similar solution implemented in my project.

You have to check for the Agent Work Status. If status is agent works status is Opened then it means agent agent accepted the work item in your example it will be case record. And you should handle this scenario in After update event.

Below is the sample code and this code should be executed in after update event of trigger.

Set<String> caseIds  = new Set<String>();
for (AgentWork aw : newList) {
  String workitemId = aw.WorkItemId;
  if (workitemId.left(3) == '500' && aw.Status == 'Opened') {    
          caseIds.add(workitemId);     
  }    
}
case c;
List<Case> caseTobeUpdateList = new List<Case>();
for(Id caseId : caseIds){
    Case c = new Case(); 
    c.id = caseId;
    c.Status = 'In Review';
    caseTobeUpdateList.add(c);

}
update caseTobeUpdateList;
4
  • would this trigger update the agent's case status update or would they need to refresh the page?
    – Atlas Can
    Jul 20 '20 at 13:57
  • It should update the case status but sometimes it will not reflect immediately so we need to refresh the page. Jul 21 '20 at 13:54
  • thanks a lot for your help
    – Atlas Can
    Jul 21 '20 at 13:58
  • 1
    Please note, this trigger changes every time an AgentWork is updated to Opened. It's not a constant status. If an agent goes offline, and comes back online, it again runs this trigger. Please make sure in which status the cases should be updated, meaning, query the Cases which are in a particular status, and update the Cases in those statuses Jun 17 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.