I am having a challenge with a recent requirement from my support team. We implemented OmniChannel and AgentWork is being routed through a mix of Skills and Queues.

Their new requirement is this: When a Case is manually assigned to an agent through the change owner modal window in the Salesforce UI, the Case should show up in the "My work" tab of OmniChannel and be counted as part of their current capacity.

I am trying to assign an AgentWork item to the User using this object but it is never recognized in the "My work" tab. I have built a Flow to go look for the AgentWork object assigned to the Case and to populate the PreferredUserId = OwnerId and ShouldSkipCapacityCheck = true as well as the AcceptDateTime = Now() and the various other fields.

Has anyone else been successful in this kind of requirement?

The Support Management gave me this as the business case: OmniChannel seems disconnected from getting capacity-based work through the Salesforce UI when work is manually routed to an Agent. We would like the calculated work to be based on both the work they accept in OmniChannel as well as the Cases that are manually assigned to them from a manager.


1 Answer 1


I have make a fell tests and looks like it is possible to the case show up in My Work tab

The only issue that I am still having is that this work item does not count against users capacity.

What you will have to do is create a PendingServiceRouting and then create the AgentWork, also you will need to enable Skill Routing, this seeams to not work with Queue routing only


Id userId = '';
Id serviceChannelId = '';
Id caseId = ''; //or another type of work

PendingServiceRouting psr = new PendingServiceRouting();
psr.CapacityPercentage = 50;
//psr.CapacityWeight = 6;
psr.CustomRequestedDateTime = System.now();
//psr.GroupId = '';
psr.IsReadyForRouting = false;
psr.PreferredUserId = userId;
psr.RoutingModel = 'MostAvailable';
psr.RoutingPriority = 1;
psr.RoutingType = 'SkillsBased';
psr.ServiceChannelId = serviceChannelId;
psr.WorkItemId = caseId;
insert psr;

AgentWork work = new AgentWork();
work.ServiceChannelId = serviceChannelId;
work.WorkItemId = caseId;
work.UserId = userId;
work.PendingServiceRoutingId = psr.Id;
insert work;


To affect the user capacity you will need also to populate the CapacityWeight on the AgentWork object

AgentWork work = new AgentWork();
work.CapacityWeight = 5;


Actually you don't need to create the PendingServiceRouting record, otherwise it can show up to another agent ( like the most available one ), so create only one or another, depending on your requirements

  • Welcome to Salesforce Stack Exchange (SFSE). Thanks for contributing - please continue to do so.
    – Moonpie
    Commented Sep 17, 2021 at 13:46
  • I'll give this a try. Has anyone tried the new OmniChannel Flows that will be coming out in Winter ' 22? I am thinking of only using the Flow tool and not Apex code to handle something like this.
    – Mayday
    Commented Sep 20, 2021 at 15:42
  • Were you able to push the AgentWork directly to the Omni-Channel console just by creating an AgentWork without a related PSR? I tested it and although the record itself (AgentWork) is created, nothing pops on the Omni widget nor the Case is sent to the Omni-Queue (the latter is expected as there's no PSR). Commented Jan 12, 2022 at 15:25
  • @user1067017 Yes! The only issue about is the agent status, the agent must be online for that channel The Case will not be sended to the Omni Queue, it will be send directly to the agent
    – nivolax
    Commented Jan 13, 2022 at 22:02
  • @nivolax I too get the message regarding the Agent status if it is not online for the Case Service Channel. However, when setting the status to online the AgentWork is created as Assigned but nothing is displayed on the agent's console nor Omni Queue (the latter one is expected since no PSR is created) Commented Jan 14, 2022 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .