0

I am currently trying to build a schedulable class that will perform several operations based on a scope of AgentWork records.

However, on the creation of AgentWork records for the test class, I am receiving the FIELD_INTEGRITY_EXCEPTION, The agent's status is not associated with the channel for this work.: [ServiceChannelId] error message.

I already took a look at similar questions such as Not able to create agentWork record in test class but didn't found any solution for the problem.

Below are the options I tried:

  • Insert AgentWork without ServiceChannelId lookup - FIELD_INTEGRITY_EXCEPTION, The agent's status is not associated with the channel for this work.: [ServiceChannelId]
  • Insert ServicePresenceStatus record - DML operation insert not allowed on ServicePresenceStatus
  • Create ServiceChannel - DML operation insert not allowed on ServiceChannel

PS.: Setting up the user running the test to Online on the Omni console while running the test is not an option as it would have to be done on the CI/CD process and that is not feasible.

Do you know if it is somehow possible to generate these AgentWork test records?

Best regards and thank you in advance!

0

For those interested: I ended up using ApexMocks framework and stubbing return data from methods.

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.