Obj-Refresh and Lock method In Pega

Hi All,

In this blog we will see Locking mechanism basics in pega. And Obj-Refresh-And-Lock.




Pega level lock basics

When someone opens an assignment, the state becomes "Perform" mode and lock is obtained by the system. The lock information is inserted into "PR_SYS_LOCKS" table in the database and it is managed there. In this period, no other user can open the same assignment. When user submits or cancel the assignment, the state becomes "Review" mode and lock is released. The record is deleted from the table. 

For more information visit below link.

Pega Lock mechanism


Note

While acquiring lock a record will be inserted in to data.pr_sys_locks (Class = System-Locks) which contains lock information like who locked and when it will be released. While releasing the lock you can see a delete operation is performed from data.pr_sys_locks table



Obj-Refresh-And-Lock


Use this method to assure that the contents of the step page are current and a lock is held on the corresponding object.

If the object is locked and the lock has not expired, this method has no effect. If the object is not locked, this method acquires a lock and if necessary replaces the step page contents with the current value of an object instance. This is useful if you are not certain whether the contents of the step page are current or whether your requestor session already holds a lock on the page.


Parameters

This method has two parameters.

1) ReleaseonCommit

Select this box if you want the system to release the lock when the next Commit method occurs for this instance. In the unusual case that you want to retain the lock after Commit — perhaps because additional changes are  expected — your activity can later use the Page-Unlock method to release the lock.

2) LockInfoPage

Optional. As a debugging aid, identify the name of a page to be created by this method to hold the results of the locking attempt when it fails. The page, of class System-Locks, contains the following properties:

pxOwnerID — Requestor who holds the lock

pxExpireDateTime — Date and time the lock will expire, or become "soft"

pxUpdateOperator — pyUserIdentifier value for the requestor who holds the lock

pxLockHandle — Text string that defines the lock

If the Obj-Refresh-and-Lock fails to acquire a lock, this page is created and can be viewed with the Clipboard tool or the Tracer.


By convention, this page is named LockInfo in standard rules. When a lock failure occurs during a flow execution, the flow can display the standard harness Work-.LockInfo (or a similar harness incorporating the standard section System-Locks.LockInfo) to report the situation. If the lock that was requested but not acquired is held by the same Operator ID in a separate requestor session, that user can click the  Release Lock    button to release the lock.


Checking the method status

This method updates the pxMethodStatus property.


Important Note:

When we checked checkbox ReleaseOnCommit.

This Lock will be released on Commit . If we not added commit method then lock will not get released

We have to use this method with more care.


Note

Make sure to enable locking in tracer settings to check runtime processing.


How to release lock ?

We can release lock on record by using a method Page-Unlock. We have to provide the step page which is locked.


Thank you!! Will see you all in next blog post 😊. 

Comments

Popular posts from this blog

pxSubscript and pxListSubscript Properties In Pega

Frequently Used Date Expressions In Pega

pyForEachCount In Pega