How to Add\Update\Retrieve\Delete a record from the Data Type using Service REST? - Part 1




I hope everyone would be aware of Data type. Let me recall.Data type is used to store reference data locally in Pega itself.  Data type is similar to data base table where we can insert/update/delete and also retrieve the records.  In any Pega Application, there will be more than one data type used. Maintaining the data type will be overhead for the teams.  In this post, we will make it interesting by maintaining the data type using Service Rest.


               
Scenario:

We have a Data Type named Customer which hold the details like Name,Phone Number,Customer ID and address. I need to add\delete\update and retrieve customer details. I have kept Phone Number as key column in this Data type.
Let’s get started . ðŸ˜Š

 We know Service Rest in Pega provides 4 methods below:
·         Get
·         Post
·         Put
·         Delete

Let me quickly explain above methods and its usage in my scenario.

1)Get - It is used to retrieve records based on the input( i.e Phone Number in my case)
2)Post - It is used to insert records(also can be used to update as well)
3)Put - It is used to update records for the given input( i.e Phone Number in my case)
4)Delete - It is used to delete the given record ( i.e Phone Number in my case)

Let’s see how it is implemented. ðŸ˜Š

GET
Here, I am going to use the GET method for retrieving the customer details for the given phone Number from the Data Type.

Currently, I have below records in the "Customer" Data type:


  •  Below is the Class hierarchy which I have used.
My main class is : OCTBK2-Int-Services
  • GetCustomerRequest- Page
  • GetCustomerResponse- Page                               
  • Next,Service REST Rule is created.

  • Now, We will add Request and Response properties.

  • Next, Service Activity is created to fetch the records from data type.



Now, we are done with defining request,response and activity. Let's execute and see the results. 😊
  • Valid Phone number.


  •  Invalid Phone Number.



To Be Continued.....

Popular Posts