Do something when process is manually stopped (Should Stop)

Hi, I need to do something when a bot is manually stop (from studio or orchestrator). For this purpose, I’m using the activity “Should Stop” to check if the process was indeed manualy stopped.

When I manually stop the process from Studio, the “should stop” activity returns “true”, so my “if - process stopped manually” works and executes the logic. The problem is that the execution stops at the middle of executing that logic, without an error.

I have placed many “trace” logs to follow the exact part where it stops inside the logic I programmed, but it stops in different parts, is not always in the same part.

I really don’t know what’s happening but the bot needs to do something when the process is manually stopped, but is currently stopping while it does that something. How can I tell Studio to stop the process AFTER finishing executing that logic?

If someone can help, I’ll really appreciate it.

I would need more context for this. Can you share a screenshot of how you’re implementing these steps?

Hi. I’m using ReFramework. Inside the framework file “SetTransactionStatus.xaml” i’m using the “check stop signal” to assign a value (this step works), but then the flow goes into the “Success” sequence.

The sequence executes and it also executes my “If - Process Manually Stopped”.
The “ShouldStop” variable is a boolean, an output from “Check Stop Signal” (is “true” when the process was manually stopped).
The problem is (for example) that the bot enters inside “WriteFinalInformation.xaml”, executes what’s in it, and then stops before executing the rest of the steps below the “invoke WriteFinalInformation”.

image

This is just one of the scenarios, since it doesn’t always stop in the same place.

It will take a deep look into your logic to do a full troubleshooting. From what I can see my best guess is this Should stop is conflicting with the should stop built in the get transaction data state of the ReFramework, in other words when it loops back to get transaction data it is overriding the initial stop signal.

My recommendation:

  • remove the activity from set transaction status
  • Change the scope of ShouldStop variable in Get Transaction Data state to make it global
  • Add your handling in a separate state on your main file, see the screenshot below
  • Set the transition condition to transactionItem is Nothing and ShouldStop
  • To make it fail safe change the condition in No Data to TransactionItem is Nothing and not ShouldStop
  • Transition from your new state to End Process

image

image

image

hope this helps.

I followed your steps and stopped the bot while it was executing the code inside “Process Transaction”, and it doesn’t move to “Manual Stop Handle” at all when I manually stop it.
It ends in the State “Process Transaction”, it enters no transition.

¿Do you have your example in code?. Can I have it to see what I’m missing?

my bad. I didn’t account for when you have more transactions pending.

Use these conditions

  • No Data: TransactionItem Is Nothing and not ShouldStop
    image

  • Manual Stop: ShouldStop
    image