Question
4
Replies
190
Views
Posted: March 15, 2018
Last activity: June 13, 2018
Closed
Solved
OOTB function pxDoesHandleExist fails if parameter passed is not a valid handle
The built-in pega function 'pxDoesHandleExist' returns 'true' if the handle exists, as expected.
However, if the parameter passed is 'garbage,' for example - the function fails rather than returning 'false' - with the message "
Class GARBAGE does not exist |
This does not fit with the use case given in the help file - where this function is meant to be used as a precondition for obj-open-by-handle so we can avoid trying to open a nonexistent instance of a rule.
Screenshot attached, please advise.
Hi,
I would think that this is an expected behavior.
The funciton returns true if an object with the given handle exists, false otherwise. If an error is encountered checking for the object, a runtime exception is thrown.
Below is the documentation for "doesInstanceExist" (you can view it from the Pega developer portal with > engine api > Database class). Based on this, if an error is encountered, you will get an exception instead of a boolean "false" return.
This method does not perform any security checking.
aInstanceHandle
- the handle (pzInsKey
) of the instanceBadClassDefinitionException
- if the instance has an invalidpxObjClass
. The processing status is set to error if this is the case.ConfigurationException
- if the database table configuration is badDatabaseException
- if something else goes wrong