Posted: 1 Feb 2018 10:08 EST Last activity: 2 Feb 2018 11:36 EST
Obj Open does not return exception or fails when an empty value is passed to the key
Obj Open method is not returning an exception if i pass an empty value to the key. But it throws an exception if i pass a junk value. Could anyone please explain if this is the intended behavior of pega.
***Edited by Moderator Marissa to update categories***
This looks to be intented behavior because when you pass the junk value it is not able to find the object in the database with this value and it can't find so there wont be any exception. But in the second case you are not passing the value to the key which is required, which is the reason behind the BadInputException as the Key value is not provided.
Thanks for the response, But still something is a miss here. I passed null to the key in the obj open method with an obj save method following it. Surprisingly both steps executed fine without any exceptions and even tracer didn't show any alerts/exceptions.
This wont create any exception but it will create an empty record in your table(assuming you did commit after save).Due to this if you did save on work page it will create Orphan record in your work table and causes many issues moving forward for example while creating work page using CreateWorkPage OOTB activity. So it is always best practice to check whether key is having value or not before doing Obj-Open or Obj-Open-By-Handle.
As explained by Mani don't perform obj-save on your page until unless you want to save the change of the right page into the database as it there might be chance of creation of stale data.
By the way the Obj-Open method with empty Key Property value the Obj-Open method is being Failed with the below failure message in the tracer,
trying to open with a key page that does not have .pxObjClass set: code: SQLState: Message:
Pega shouldn't allow you to save the activity if the mandatory property key value is empty. I think this is already fixed in the latest versions, will check and let you know if any fix available for your version. Let me know your Pega version.
If the Obj-Open is Failing then you shouldn't perform the Obj-Save method.