Return From A Workflow

Hello all,

I am working on a complex business use case where there a lot of scenarios where I need to terminate the workflow in between the process. Like if it is an invoice processing in SAP then there may be chances that the data required for the automation is not provided so in that case I would want to terminate the workflow, so that it cannot go the next step in the sequence. Right now what I am doing is throwing an exception on all such type of issues but that’s definitely not the right way to do it.

Thanks a lot in advance!

Hi @himanshu_punj1

You can use the ‘Terminate Workflow’ activity in order to do so.

image

Edit: The best practice is using the try-catch to encounter such errors and handle them accordingly. Using a framework such as RE (Or your custom exception handling template), you need to handle such errors with appropriate exception messages and proced next transaction retrieval.

Hope this helps,
Best Regards.

1 Like

Hi @arjunshenoy thanks for your reply.

I looked at that activity earlier and I think that is the same thing that I am doing right now - it’s basically the abrupt ending of the workflow. What I want to do is return, like we use return keyword with functions in any programming language so that we can end the execution in a nicer way.

Thanks!

@himanshu_punj1
method 1. use flowchart

method 2. use throw exception inside try catch


image

1 Like

as per your details it looks like the case needs to be marked as business exception

if you are using REframework that will automatically handle the case , the only thing you need to do is returning the application to initial state to take up next case

Regards

1 Like

@himanshu_punj1

Well, in that case, you can use the ‘Global Exception Handler’ where the control is moved gracefully to the referred workflow and you can handle/end the same in your way. Please note that no matter where the exception is thrown in the process, it will trigger the GEH.

Best Regards.

1 Like

Hi @jack.chan I was looking at that earlier and looks like flow charts and state machines are the only ways to go further with it. But still curious if someone has any different ideas.

you can try my second method too, basically throw exception but inside try-catch block so that you wont run the subsequent steps in the workflow but you can still return output gracefully @himanshu_punj1

1 Like

Hi @LAKSHMI_NARAYANA_PEMMASAN thanks for your reply.

Well, I am already doing that but it doesn’t look good to throw exception on a case that is well known. Consider an invoice processing example where we do have a scenario where the invoice is partially processed, in this case we know that is not an issue, this is something the part of the process. so, there must be something by which we can achieve this functionality.

Hi @himanshu_punj1

For the above case, you can have data validation using flow decision where actually you can validate the data, before going to SAP

If you don’t want to throw an exception, you can use flow decisions to validate the case and then execute the respective sequence action. If you choose this, you might have to use a lot of flow decisions to validate each case.

Besides, this Throwing a business exception and updating the final log with the customized exception is also good approach. This way, you need not to search for a particular log message (this applies when you use flow decisions), when the bot not able to process any invoice as the logs and queue status updates with the particular exception. Also, the business knows what exactly the issue with the input data

Currently, there were few different options in the tool to handle exceptions:

  • Try Catch
  • Throw
  • Rethrow
  • Terminate
  • Global Exception Handler

It looks like you have explored all these. Global Exception Handler is a workflow where we can built a logic to identify the exception and retry the previous step. I guess it doesn’t suit to your case since re-trying does not help sometimes in SAP.

1 Like