Obj-Refresh and Lock method in pega
Hi Everyone, in this post we will see how to use Obj-Refresh and Lock method in activity.
PDN Help Link:
This method we will use to acquire Lock on work object. Whenever we want we can acquire lock by using this method.
We opened the instance without lock . In later steps we need to get the lock on work object means we can use this method.
If we not sure whether we acquire lock or not then we can use this method to acquire lock.
If work object is already locked then this method will not affect.
Lets check Obj-Refresh and Lock by an example.
We have a data class Courses having some number of records. Will try to acquire lock on this instance by using Obj-Refresh and Lock Method. Before using this method we have to make sure that whether that class support locking or not.
How to check whether class support locking or not?
If we open class definition we can see Locking tab there we can see Allow Locking check box.
Locking tab of Class rule:
Lets check Obj-Refresh and Lock by an example.
We have a data class Courses having some number of records. Will try to acquire lock on this instance by using Obj-Refresh and Lock Method. Before using this method we have to make sure that whether that class support locking or not.
How to check whether class support locking or not?
If we open class definition we can see Locking tab there we can see Allow Locking check box.
Locking tab of Class rule:
So now we know that this class allow locking on instances.
Lets write an activity to acquire lock on one of these instances.
In below activity we used Obj-Open to open courses class record without lock whose ID is "END-001" . So we not acquire lock yet.
In third step added Obj-Refresh and Lock method to acquire lock.
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.
Added Commit step.
Lets test this by trace this activity :)
Make sure that you enabled locking in tracer settings to check this .
Activity got run successfully.
Lets check tracer,, In below image if you see on executing Obj-Refresh-And-Lock method Acquire Lock happened.
On Commit Release Lock happened.
While releasing the lock you can see a delete operation is performed from pegadata.pr_sys_locks table. Means while acquiring lock a record will be inserted in to this table which contains lock information like who locked and when it will be released.
Hope you understand about Obj-Refresh and Lock method.
Lets comment Commit method and execute this activity and look at the instance from System-Lock class.
From the below image you can see that lock is acquired but not release since we commented commit step.
So now this record will be there in System-Lock class.
Here you can see our record list here in System-Locks instance.
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.
Tracer:
In the above image you can see Page-Unlock method released the lock.
Hope u guys understand this post. If have any doubt ask in comment section