Search code examples
pega

How to search if a value exists in table


I am trying to delete records via GUI. I have a text input in my section mapped with property (.EID) which intakes employee ID (for example 1) and when i click a button 'delete' that particular record should be deleted from DB. I have written an activity that successfully deletes.

But I want to display a message if the entered employee ID is not present in the table. For example if I have already deleted record 1 and the user again tries to delete record 1 it should display a message saying "employee doesn't exist, please enter existing ID". I have used obj-open->obj-delete->commit to delete the records.

Please help me how to achieve this.

I have attached screenshot of my GUI, for example i have already deleted record no 2, so when user again enters 2 and clicks on delete button it should display a message saying "no such user".enter image description here


Solution

  • You can launch a local action(flow action) on the delete button. In the pre-processing of the flow action call one activity. Pass the employee id as parameter to the activity. In the activity do obj-browse on the table and add filter on employeeid column. Store the count of obj-browse in a property. If the count of the obj-browse is greater than 0 then delete the record. The section of flow action will display 2 messages based on when condition. One message will become active when count is greater than zero which will display Account deleted and another message will get active when count is zero which will display account does not exist.