# How to Get the Lock of a Case

**URL:** <https://forums.pega.com/t/how-to-get-the-lock-of-a-case/9331>\
**Category:** General\
**Tags:** platform, other-industry, pega-platform, senior-system-architect\
**Created:** [April 9, 2025, 8:05pm UTC](https://forums.pega.com/t/how-to-get-the-lock-of-a-case/9331 "2025-04-09T20:05:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeandroTaveira](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/leandrotaveira/32/23391_2.png) [@LeandroTaveira](https://forums.pega.com/u/LeandroTaveira)\
**Post date:** [April 9, 2025, 8:05pm UTC](https://forums.pega.com/t/how-to-get-the-lock-of-a-case/9331/1 "2025-04-09T20:05:51Z")

</div>

**About Case Locking Strategies**

Pega offers two primary case locking strategies to manage concurrent access:  
1.Pessimistic Locking (Allow one user) - Only one user can access and edit a case at a time. Other users cannot update the case until it’s unlocked or the lock expires.  
2.Optimistic Locking (Allow multiple users) - Multiple users can work on the same case simultaneously. When changes are made, users receive notifications about updates from other users.

**Implementing Programmatic Case Lock Checking**

When you don’t have the lock but need to perform actions on a case, follow these steps to implement a programmatic check for case locking:

1 - Create a Activity

- Create an Activity called ‘_GetLockObject_’ on your work class (in my case ‘_HTP-HowToPega-Work-SampleCaseType_’).

2 - Configure Your Pages and Classes

- Add your ‘_pyWorkPage_’ in pages and classes referencing your work class (‘_HTP-HowToPega-Work-SampleCaseType_’)

 ![Image01.png](https://pega1.discourse-cdn.com/pega/original/3X/8/f/8f826d4f30f7cc631eee90476c86eb0da7b45415.png)

3 - Configure your activity  
There is only one main step in the implementation process:

- Use the method ‘_Obj-Refresh-And-Lock_’ to ensure that a step page’s contents are current and that an object is locked
- Set the ‘_pyWorkPage_’ page to the ‘Step Page’

 ![Image02.png](https://pega1.discourse-cdn.com/pega/original/2X/6/6f68627bd9bff0eb7a32d74eaf5c283177e8e551.png)

- Set the When condition to check if the page is locked:
- When: _@isPageLocked(tools,myStepPage)_
- if true: Exit Activity
- if false: Continue Whens

 ![Image03.png](https://pega1.discourse-cdn.com/pega/original/2X/c/c6eca823adb9bcefe27829e4b3ceed3f6c736b56.png)

This implementation ensures that your application properly handles case locking scenarios, preventing data conflicts when multiple users attempt to access the same case.

References:

- [Pegasystems Documentation](https://docs.pega.com/bundle/dx-api/page/platform/dx-api/supported-features-case-locking.html)
- [Pegasystems Documentation](https://docs.pega.com/bundle/platform-241/page/platform/case-management/managing-concurrent-access-case.html)
