Nested Invoke Workflow Activity

Hello, People of the Earth,
I am facing an issue using Invoke Workflow.

Workflow:- I am using an Invoke Workflow inside another Invoke and both are having Try-Catch, then I Terminate it using the Terminate Workflow Activity at the end of the Catch to close the flow.

Problem:- If an exception occurs in the second Invoke, the bot runs the catch for both Invoke 2 followed by Invoke 1. We are making an entry in the Database in each Catch, and because of the above issue, two database entries are made.
please let me know if anyone else faced this kind of issue and what will be the possible solutions.

1 Like

@modsoul what solution your expecting for it? can u explain it?

@Manjuts90
I am expecting it to just terminate in the second workflow catch itself, rather then running the catch of the second Invoke as well.
Is there any other activity I can use to just Terminate the workflow then and there in place of terminate Workflow.?

@modsoul The inner most workflow is already in completed stage once it have reached catch block. You dont have to use Terminate workflow activity at end of Catch block unless you are looping the inner most workflow.

You can use Throw activity with custom message.

  • In Invoke2, have you mentioned system. exception in both the invokes?.
  • If no, please mention it. Because if the exception are different, both the catch will be triggered.
  • If yes, debug your code. In output, search the keyword faulted. Now you can easily find what makes the catch to get triggered

@Vivek_Arunagiri
Yes, I have used system.exception in both Invokes as both are triggering different Exceptions.
I don’t understand the Second point you have mentioned, can you please elaborate it a bit for me to get better understanding.

Instead of Run, Go to Execute tab and click on Debug. This will run you code in debugging mode.

image

Now the log will be captured for each activity. Once execution is complete, In output search the keyword faulted. Now you can easily find the issue.

image

@Vivek_Arunagiri
Thanks for the Quick Reply,
I know what is the reason for the Error, Actually I am creating the Error myself.
What I wanted to know was, why the Bot will run the 2nd Catch and also the Catch for the 1st one.
Is that how it is designed to run or is it a problem in my workflow?

Actually, 2nd catch should have not been triggered. There should some issue in workflow only.