Question
hcl
IN
Last activity: 11 Dec 2019 23:01 EST
How to search if a value exists in table
Hi Guys,
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 amessage saying "employee doesnt exist, please enter existing ID". I have used obj-open->obj-delete->commit to delete the records. Please help me how to achieve this.
Help is very much appreciated!!
***Moderator Edit-Vidyaranjan: Updated Platform Capability***
-
Like (0)
Siripuram Mahesh Vachan Chauhan -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
hcl
IN
Hi Guys,
Can anyone help me please!
-
Shreya Kumari
BPM Company
NL
One of the possible solutions:
1. Use Obj-Open with filtering: .EID is equal Param.EID. Lets say, your page name is EmpList
2. Then apply when condition on the next step: if EmpList.pxResultCount == 0 then set some property, say, .ErrorMessage = "Employee does not exist"
3. On the button's action list, add Refresh Section
-
Yemineni Manjulatha
hcl
IN
Hi Vaspoz,
I did not understand, could you please elaborate steps. How to apply filter in obj-open? there is no such option. I understood but need help in applying it.
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:.
BPM Company
NL
What Pega version do you use?
Looks like 8, but I'm not sure.
Anyway, if >8 than you can check - they introduced new type of Data Page - saveable (along with Read only/Editalbe). It does exactly what you want.
Could you check this option before we consider other ways?
hcl
IN
Thanks, I will check it out, but meanwhile i have tried something, i am attaching a doc, please check and help me. Message is set for both true and flase output of when condition in property-set-messages.
BPM Company
NL
You didn't attache the screenshot with when condition expanded
Collabpartnerz
AU
Hi Jeevan,
I would suggest you to use Obj-Delete-By-Handle if you are sure about the key of the instance (i.e., pzInsKey).
This method depending upon the delete operation sets the corresponding step status - Like Good / Fail / Warn.
- Fail - If the instance doesnt exist in the table (Your scenario)
- Fail - The class enables locking , but the lock cannot be acquired as it is held by another user.
- Warn - Lock is selected, but the class is not allowing you to lock the instance. The object will be delete though.
In the step transition you can use below when conditions to jump to respective step for setting appropriate messages.
- StepStatusLocked - To Check if the instance was not deleted due to issue with acquiring lock.
- StepStatusFail - To check if the instance does not exist in the table
- StepStatusGood - To check if the instance is deleted with out any issues
Benefit of this approach vs your approach is number of DB hits you would have in your approach.
In your approach, while it works fine, for deleting 1 record you are hitting DB 2 times.
- when using Obj-Browse for browsing to check the records and
- when running 2nd for acquiring lock and deleting.
Swedbank AB
SE
Hello Jeevan,
Have you considered using OBJ-OPEN-By-HANDLE instead? It ensures Handle to the Instance - must match the pzInsKey value to successfully open the instance.
You may alternatively use your activity to flag if the object exists and then probably proceed deletion steps.
Thank you,
Pawan