Terminate the workflow at specific time without message box

Thorw doen’t terminate the workflow.Basically I want to terminate the workflow at specific time to stop the process.

1 Like

Hi All,

Even i want to terminate my workflow in between of some operations. Could anyone help me please.

Many Thanks,
Balakrishna Reddy

1 Like

use try-catch…Pass terminate workflow activity in it.

1 Like

this is not working… Message box is shown as above. I don’t want message box to appear.
How this Terminate Workflow is used without message box being popped up?

Then why this Terminate Workflow activity is introduced ? and for what purpose?

Can you try this inside Invoke Workflow Activity?

Target Object : System.Diognostics.Process.GetProcessesByName(“UiRobot”).First(Function(p) String.IsNullOrEmpty(p.MainWindowTitle) = false)
Method Name: Kill or CloseMainWindow

1 Like

I want to understand the functionality of Terminate workflow activity and how we can utilize it to stop the workflow without a popup message box.

see this screenshot.

Now in catch, do not print any exception message… only the text you want to print…e.g. “Error found in RZ20 T-code” something… and then use terminate workflow activity PRIVATE. It will definitely work. If you dont wanna print any error, then you can use directly workflow activity (PRIVATE).

HI Chand,

I tried what you have suggested, still the pop up appears.

Attached are the screenshots. I have added a try catch block. Thrown an exception in try and caught that exception in Exception block, set the required properties as you mention. Still the pop up box.

Kindly check and confirm.

you have 3 exception mentioned in catches and your trying to terminate the workflow without passing any exception type in “exception” field in the property.
please pass the value and try.

In all the exception blocks I have added the exception object.
Now, I have removed 2 exceptions and kept only 1 exception (with exception object). Still the pop up comes up.

Hi,
Exception field of "Terminate workflow is still kept empty.
Please pass the exception variable there.

Oh, I thought either Exception or Reason property should be set. Well, I set the exception property now. (This terminate workflow is already in catch block.)

exception name you declared in the catch block is “exception” not “New Exception
please pass “exception” in the property …:upside_down:

Tried with that also. No luck .

Can you create a simple workflow for this Terminate Workflow and attach it here so that I will test ?

Here we go. cheers.:+1:
Main.xaml (10.5 KB)

2 Likes

yes, that worked… Thanks.

So you have added a Try catch inside a Try catch block. That’s the way to implement it. Now got it.

The TerminateWorkflow activity in that workflow never executes - Throw before it will abort the execution of current context level.
Sidenote - swallowing exceptions (as in - Catch that does nothing, not even log message) is not recommended and should be done very carefully (I’d say never, but that’s IMHO).

@Chand - are you sure setting it to Private works? Did a quick test, and it doesn’t seem that way. AFAIK setting to Private will only make it not log anything (and it does just that), it doesn’t change the way it behaves. There has to be something else in your workflow that makes it look like it’s working.

Sidenote - TerminateWorkflow activity bypasses Catch clauses in the same workflow and can only be caucght higher in the invoke hierarchy, unlike normal Throw’s.

Most reasonable solution is either what @adrian posted (just throw an error and catch it at the top) or use a flowchart and exit on condition.

See above in my post - it bypasses Catches in current workflows and is the equivalent of telling the robot to “exit this workflow NOW”.

Yep. I believe the Terminate Workflow activity is supposed to throw a popup because it’s basically telling it to stop cause of error. Equivalent to Terminating in Orchestrator.

I would just go with flowchart condition or put all sequences in a Try/Catch with a Throw error when condition is met… or something like that.

Close, but TerminateWorkflow is actually a Microsoft provided activity, so it has nothing to do with Orchestrator.
The popup is a result of an unhandled (as in - not caught) exception, nothing more, nothing less. There are some internal differences on how it works (Terminate sets the workflow to Faulted, while Throw sets to Canceled etc.), but for the most part one does not need to dig that deep since the robot handles that.

2 Likes