Fetch out the difference case ID from the data page.

This is a general case for the data page fetch out a case result with the oldest create time. When multiple users calling the same flow, the same case (with case ID) would be fetched out. Which the ID would be immediately set to the case assignment by the OOTB Work-.pxTransferAssignment.

I would like to seek for any advises to solve the issue that the system would like to get another case for Case assignment as the system design is not allow duplicate user to working on the assigned case.

Thanks.

Ticket number from the support: INC-C13411

@AndrewW16838926 as per the suggestion in the closed support ticket, please engage with consulting team to provide more information on the design change.

If you have resolved it, please post your solution here in a reply and mark it as accepted solution. If you still need help, see below:

:warning: This is a GenAI-powered tool. All generated answers require validation against the provided references.

You are writing about a race condition issue with the “Auto Get” button in your Pega implementation.

I understand that when multiple users click this button simultaneously, the same case is being assigned to different users, even though it should only be assigned to one user. This is a classic race condition problem that occurs when concurrent operations try to access and modify the same resource.

Based on your description, I’ve identified several approaches to solve this issue:

1. Implement Optimistic Locking with Status Tracking

The most effective solution would be to modify your data transform to implement a status tracking mechanism with optimistic locking:

  1. Add a new property to your case class (e.g., pyAssignmentStatus) that can have values like “Available”, “InProgress”, or “Completed”.
  2. Modify your data transform to:
    • First check if the case status is “Available” before attempting to assign it
    • Immediately update the status to “InProgress” when a case is fetched
    • Include this status check and update in a single transaction to prevent race conditions

Here’s a conceptual approach for your data transform:

// Step 1: Query for available cases with a WHERE condition that filters for "Available" status
SELECT * FROM YourCaseClass WHERE pyStatusWork != "Resolved-Completed" AND pyAssignmentStatus = "Available" ORDER BY pxCreateDateTime ASC

 
// Step 2: In the same transaction, update the status of the selected case
obj.pyAssignmentStatus = "InProgress"
obj.pyAssignedTo = UserIdentifier
obj.Update()

2. Use Pega’s Built-in Locking Mechanism

Configure your case type to use the “Allow one user” locking strategy:

  1. Navigate to App Studio > Case Types > [Your Case Type] > Settings > Locking
  2. Select “Allow one user” in the “Access strategy to open and work on a Case” section
  3. Set an appropriate timeout value (default is 30 minutes)

This will ensure that when one user accesses a case, it’s locked for other users until the lock is released or times out.

3. Implement a Synchronized Activity

Replace your current data transform with an activity that uses synchronized Java code:

  1. Create a new activity that will handle the case assignment
  2. Use the synchronized keyword in Java to ensure that only one thread can execute the critical section at a time
  3. Within this synchronized block, fetch and assign the case

Example Java code in an activity:

synchronized(this.getClass()) {
  // Fetch the oldest available case
  String caseID = tools.findPage("YourDataPage").get("CaseID");
  
  // Check if case is already assigned
  if (caseID != null && !isAssigned(caseID)) {
    // Mark as assigned
    markAsAssigned(caseID, tools.getAuthenticatedUserName());
    return caseID;
  } else {
    // Return null or handle the case where no cases are available
    return null;
  }
}

4. Database-Level Locking

If your database supports it, you can use database-level locking mechanisms:

  1. Modify your SQL query in the data transform to use SELECT FOR UPDATE which locks the selected rows
  2. This prevents other transactions from modifying these rows until your transaction is complete

Example SQL:

SELECT * FROM YourCaseClass WHERE pyStatusWork != "Resolved-Completed" ORDER BY pxCreateDateTime ASC LIMIT 1 FOR UPDATE

Recommended Approach

Based on your specific scenario, I recommend implementing the first approach (Optimistic Locking with Status Tracking) as it provides the most robust solution while maintaining good performance. This approach:

  1. Adds a status field to track assignment state
  2. Updates this status atomically when assigning cases
  3. Prevents the same case from being assigned to multiple users
  4. Handles race conditions gracefully without requiring heavy locking

This solution addresses the core issue where the data transform is returning the same case ID to multiple users when they click the “Auto Get” button simultaneously.

References:

If this answered your question, please click ‘Accept Solution’

@AndrewW16838926

The pxAssignedOperatorID, pzInsKey(based on your transfer from Worklist to Workbaseket) on the case would be set by pxTransferAssignment.