Posted: 9 Dec 2019 14:04 EST Last activity: 11 Dec 2019 11:24 EST
Need advice for QueueForAgent
How does Pega recommend that we use QueueForAgent? What class should I queue? Should it always inherit from System-queue?
We use a lot of custom agents to automate our process. Before I joined the team someone coded a flow to call QueueForAgent using the primary work- page. They did not create a separate class to simply queue the key of the case. They queued the entire work object. I don't like this because I can't tell if Pega's code refreshes the case before the agent begins processing or if it is working with a stale copy. To complicate things the developer used obj-refresh-and-lock to get a fresh copy of the case using the release lock on commit option at the top of the agent code. I think this code is just creating a conflict with Pega's internal agent code leading to issues. We are having sporadic issues where assignments are lost. Unfortunately there are no errors in the logs to help me fix the issue.
In another part of our application that is more reliable the developers opted to create a separate queue class that inherits from system-queue to simply queue up the key to the case that needs to be processed. The agent code opens the case and calls resumeflow to process the work.
I have looked at some of the OOTB pega agents. PRPC mostly queues up either assign- or system-queue- classes. I've seen some framework agents processing work- queue records but they don't seem to be doing flow processing.
btw - I have read articles like https://community.pega.com/knowledgebase/articles/system-administration/how-create-agent to refresh my knowledge but I never found a firm example of how to pull it all together. In the end I have a flow that stops at an assignment. I want that assignment to be processed by an agent because it is a waste of time for a human to do the work. I want to queue up the case or assignment and let the agent run the one and only flow action connected to the assignment.
Before the assignment I need to call queueforAgent. What class of record should I queue?
What should the agent activity do before calling ResumeFlow? Should it open the work object and lock the work object?
I don't think that will work. The new assign page will not exist until the flow reaches the assignment shape. When that happens the flow stops and will not reach the shape where queue-for-agent is called. At the moment my flow calls Queue-for-agent first before parking at the assignment. I'm sure that this is the main reason for the previous developer queuing the entire work object.
Is there another way to do this? I'd rather queue the newAssignPage but I'm not aware of a way to add custom logic that will be called when the flow parks at the assignment.
After trying some code changes I was able to confirm what I knew already. Queuing the entire work object is not the best choice. It is better to queue a class that just provides a handle to the work that you need to process. For example just queue the pyID of the case. The agent activity needs to explicitly open the work object and perform an operation like resumeFlow or other logic to complete the desired work. The previous developer was under the false impression that he could queue the entire work object and Pega's agent code would handle refreshing and locking the case for processing. From what I've read and experienced Pega's agent code is only going the manage the queue record itself. The rest of the work needs to be coded in the agent's activity.