Delete a case in Pega

 Delete a Case


In this post, I am going to explain you about how you delete a Case in Pega. A Case is a work that you would like to accomplish. It is also referred as Work object. In Pega, we create a Case based on case type that is defined in the application. Once Case/work object is created,  it traverse through various stages and it is resolved once it accomplishes the work . 
            In general, in production systems , once an work object/Case is created, we do not prefer to delete the case rather than mark it Cancelled or void the case. If it requires to be deleted still, then we would need to follow certain process set by business before it is deleted.  As a best practice, avoid deleting the case in Production environment. 
        While developing, you may require to delete the case due to environment memory load or due to performance issues. We do not have separate wizard to delete a case in Pega. So, let's us see how to delete the case using below steps.

        Here, i have created an activity to delete a case which can be used as utility too. 😊

Activity Parameters:
  1. Class- Name of work class 
  2. Caseid- Case id to be deleted


Logic:
  1. Create a Page to hold the Case pzinskey
  2. Fetch the case pzinskey using the class /Case id passed using Obj-Browse method.
  3. Pass the pzinskey to Obj-Delete-By-Handle.
  4. Use Commit method.
Here, is the screenshot from Activity in case if you have passed Class Param only. 

Note: It would delete all the cases instances created in the class as Case id is not passed.


Iterate the case list and pass the key to Obj-Delete-By-Handle and perform Commit.




Next, few snapshot from activity in case if you passed Class and Case Id param.



Pass the pzinskey of Case id passed to Obj-Delete-By-Handle method and perform Commit.


Now,  Save your changes and Click Actions->Run to execute the activity.


Now, Click-> Run and the case is deleted successfully. 

Happy Learning!!

Popular Posts