Sunday, 30 June 2019

Obj-Refresh and Lock method in pega

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:



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

Understanding a Activity How it works

Hi Peers,

Today  we walk you through in this post regarding simple activity to understand the rule behind scene :)


A simple activity can update a property for one operator ID instance by opening the instance, updating the clipboard page saving the updated clipboard page, and committing the result to the database

First the activity opens an operator ID record, based on the value of a parameter, and copies the data from the database to a clipboard page. Next, the activity updates the user locale update time and name of the user who updated the record. Finally, the activity saves the updated page back to the pega database, making the updates permanent.

Each step of the activity and its corresponding method are described below,

On the Parameters tab define the parameters that identify the operator Id to be updated and the new locale value



On the Pages & Classes tab enter the name of a page that holds the contents of the Opertor ID record that is returned by the Obj-Open method.



On the Steps tab, do the following.

   Add an Obj-Open method. This method opens a single record from the database and copies in to a clipboard page.

 Enter the values shown below to specify that the value of the .pyUserIdentifier property on the Operator record equals the value of the parameter that is defined on the Parameter tab.





Note : Methods that return data from an object (such as Obj-Browse and Obj-Open) .Put the returned data on the step page.

If your application updates and saves the instance select the lock check box to prevent other requestors from updating the instance while your requestor is using it.

Add a Property-Set method to update the .pyUseLocale  property and two other  properties. List the Step page again. This provides context for the properties that are selected so you do not need to provide the page name before  the period that precedes the property name.

Note: @CurrentDateTime() is a standard function rule that returns the current system date and time.



Note: For activities that are used in flow processing, do not include a Commit step. Built-in activities contain Commit methods at the appropriate places.




At this point, you can test the activity. After you run the activity, you can see the updated data on the Operator ID rule form. To help with testing, include a Show-Page method to display the Operator page contents before or after the Property-Set step.

Testing the example

To test the activity, do the following steps:
  1. Click Actions > Run.
  2. Notice the parameter names; these are the names that you defined on the parameters tab.
  3. Enter a value for each parameter.
  4. Click Run to start the activity.

Run parameters

When the processing reaches the Show-Page step, the page contents appear as an XML document in a browser window.

The page output appears as shown below. Notice the pyUserIdentifier and the updated pyUseLocale values.


Note:  Remove the Operator page from the clipboard by adding a Page-Remove method. This frees up memory that is no longer needed.  In the Step page field, enter the name of the page to be removed.

Cheers,

Hope you understand. If you have any queries ask in comment section.

Thanks peers :)

Thursday, 27 June 2019

Use of Wait Method in Pega

Use of Wait Method in Pega


Hi everyone, Today we will see how wait method will works in pega,

 Pega PDN help topic about wait method:

 ttps://community.pega.com/sites/default/files/help_v718/methods/wait/wait.htm

From my understanding , this method will pause the thread for specific time period that we mentioned in the method.

From the PDN Help we can come to know that this method will perform Java sleep.

This method has 2 parameters

  1. Second- How many seconds have to wait.
  2. Miliseconds- How many miliseconds have to wait.
Lets use this method practically and know the usage :)

 I added wait method in the activity provided wait seconds as 60 seconds. So after 1 mins only page-remove step will execute.


Lets trace this activity and check this . 


From the above pic you can see that wait method started and waiting for 1 mins to complete. 


After One minute method got completed and third step executed.

I hope you guys understand this topic. :)