Showing posts with label OBJ-Open in pega. Show all posts
Showing posts with label OBJ-Open in pega. Show all posts

Sunday, 30 June 2019

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 :)

Wednesday, 24 October 2018

Obj-Delete and Obj-Delete-By-Handle in Pega

Obj-Delete and Obj-Delete-By-Handle in Pega


Today We will see how to use Obj Delete in Pega and how to use Obj-Delete-By-Handle in Pega.

This method is used to delete record from database. What is the difference between these two method??

  • If u don't know the Key (pzInsKey) of the record and U have to delete the record then U have to use Obj-Delete. 
  • If u know the Key(pzInsKey) then U can use Obj-Delete-By-Handle to delete the exact record.
Lets see how to use these two method in pega.

OBJ-Delete-By-Handle

My Local Table record is shown below.

Now lets create one activity in Work class and Write Code to Delete the record in this table.


Now I am going to delete a record from Table where Title is "Insurance Options" for that I use Obj-Browse

Now it will retrieve the record where title is Insurance Options. And U can see GetRowKey is enabled, that means it retrieve key also to clipboard. 


Lets Check key is available or not in clipboard.


pzInsKey is there so we can use this key to Delete this record. Lets Do it



Now in 3 rd Step I Loop through all the records available in CourseRecords.pxResults PageList and Copy the Key to a Local Variable Named Key.

In 3.1 th Step I used Obj-Delete-By-Handle 
Here I pass the Key Value to Delete . This indicates we are going to delete the record having the provided Key.

After this step I used Commit Method to Complete the process.

Lets Run and See whether it is deleting or Not.


Activity Run successfully Lets check in Local Table whether value is there or Not.


Now u can see the record is not there in table. We Successfully deleted a record. :)

OBJ-Delete

Lets See How to use Obj-Delete.

I will use this Method When I don't know the Key Value. Lets Delete the record having ID = SAL-002

I used Obj-Open to get the record in Clipboard.

Lets See whether Obj-Open retrieve values in Clipboard
.

Data is there , Now we can delete this record.


Now I added the Method Obj-Delete and Enabled Remove and Immediate Check Box.

And at last I added Commit to complete the transaction.

Lets Run the activity and test whether Record is deleted or Not.


Now U can see the record is not available after delete.



U can see SAL-002 record is not here. Thank u friends for reading and learning with me.If any doubt ask me in comment . Bye :)