I have to check an excel every day, if it’s empty I want the process to end, but I can’t, I’ve tried as shown in the image, but it doesn’t do anything, I think I’m not doing something right.
Any idea, to finish and not carry out the following steps in case the excel is empty.
Hi @Aguirre ,
Try to use TerminateWorkflow activity instead of throw activity which will help you to terminate the process. thanks.
Hope the below steps would help you resolve this
Use a excel application scope and pass filepath as input
Inside the scope use a read range activity and get datatable dt as output
Now use a IF activity like this
dt.Rows.Count > 0
If true it goes to then block which means it has records and you can have the activities you want
But if it is false it goes to ELSE block where use a TERMINATE WORKFLOW activity which will terminate the workflow at that instance
I have tried what you have told me and you have followed the process, but it has not finished, perhaps something is wrong with me.
Hi @Aguirre , any chance you can copy the code or an example here? Will be easier to understand what you’re doing with your current structure !
In addition, your “Throw” approach is correct, that’s how you should handle the errors, and depending on the error, you just need to redirect the bot to the end stage (if you’re using the ReFramework)
I created a simulated workflow to explain the approach I’d take in this case (assuming you’re not using reframework)
1- Main TryCatch
- Will be in charge to stop your process if you throw a BRE, in this case, Excel Empty.
Inside, you have your “X” steps, and Excel is one of them, if there are 0 rows (empty), you’ll throw an exception like you did correctly before:
The bot will identify the Throw Error, and will jump to the catch of the main Workflow, where you’ll log a message stating the failure reason, and the bot will end there:
It will reach the end, and will stop the process.
How do TryCatches work?
It will process everything until a SE or a BRE are found, then it will jump to the catch (if it exists)
It will perform any action needed in the Catch, in our case log the message with the exception details, and it will reach the end. In this case, since there are no more actions below, it will stop and finish:
Attaching the dummy project I created, feel free to press play and see the steps it does
DemoStop.zip (55.6 KB)
Hope this helps!
Actually these step doesn’t need TRY CATCH block and is pretty straight forward
First of all, thank you for the time you took to answer me, I was testing @Palaniyappan idea, it’s simpler and as it works, it will be the one I implement.
Thank you very much for the idea, many times we get complicated and the solution is much simpler as in this case.
Glad it got resolved @Aguirre
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.