# How to handle invalid rule name or determine if rule is accessible without calling it

**URL:** <https://forums.pega.com/t/how-to-handle-invalid-rule-name-or-determine-if-rule-is-accessible-without-calling-it/3105>\
**Category:** General\
**Tags:** 8-5-1, system-architect, case-management\
**Created:** [August 17, 2022, 5:32pm UTC](https://forums.pega.com/t/how-to-handle-invalid-rule-name-or-determine-if-rule-is-accessible-without-calling-it/3105 "2022-08-17T17:32:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hermy64](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@Hermy64](https://forums.pega.com/u/Hermy64)\
**Post date:** [August 17, 2022, 5:32pm UTC](https://forums.pega.com/t/how-to-handle-invalid-rule-name-or-determine-if-rule-is-accessible-without-calling-it/3105/1 "2022-08-17T17:32:43Z")

</div>

I have need to call an Activity dynamically based on having a string of the name of the Activity you want to call. I’m aware you can do this using a function via doActivity or pxExecuteAnActivity.

Here’s the problem, we need to build a list of Activity name strings before those Activities are actually created to avoid a dozen devs constantly conflicting with one another to update the same rule to add their Activity name to the list (it’s a Decision Table). The process that runs is automated to run every Activity in the list but the problem is Pega does not gracefully handle attempting to invoke a non-existent rule. It does not trigger StepStatusFail nor does it detect an exception. It simply terminates the currently running rule and ends the process, robbing you of the ability to handle the error and continue.

There is an ugly work-around of creating a dedicated Activity that only does the dynamic invocation and then whatever calls that can detect an exception on it. I’m hoping the Pega platform has something more graceful than this though.

Alternatively, is there anything we can call to determine if a given Activity exists and is accessible (as determined by proper rule resolution… not merely finding an instance of the rule in the rules DB as some functions do)?

---

<div class="post-metadata">

**Author:** ![Deivit](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/deivit/32/182_2.png) [@Deivit](https://forums.pega.com/u/Deivit)\
**Post date:** [August 17, 2022, 6:25pm UTC](https://forums.pega.com/t/how-to-handle-invalid-rule-name-or-determine-if-rule-is-accessible-without-calling-it/3105/2 "2022-08-17T18:25:16Z")

</div>

@Hermy64 I tried to invoke a non-existent activity using the doActivity function and it thrown an Exception. So, try to wrap your code with a try-catch-finally and continue the execution.

Sorry for not being able to help more.

---

<div class="post-metadata">

**Author:** ![Hermy64](https://avatars.discourse-cdn.com/v4/letter/h/0ea827/32.png) [@Hermy64](https://forums.pega.com/u/Hermy64)\
**Post date:** [August 19, 2022, 5:17pm UTC](https://forums.pega.com/t/how-to-handle-invalid-rule-name-or-determine-if-rule-is-accessible-without-calling-it/3105/3 "2022-08-19T17:17:29Z")

</div>

@Deivit Thanks I didn’t think to try my own Java wrapper but that works. Not a great look for the platform but good enough as a work-around.

If anyone’s interested here’s the Java step contents

> try {
> 
> pega\_rulesengine\_utilities.pxExecuteAnActivity(tools.getStepPage(), “MyActivityName”);
> 
> }
> 
> catch (Exception e) {
> 
> }

The above will trigger the “On Exception” jump instead of abruptly terminating the Activity.
