When is exit section used in state activity of state machine?

When is exit section used in state activity of state machine? Can you explain with an example?

@Forum_Staff Do you have any answer for this question? I’ve seen multiple forum topics, searched in google, tried a lot to find examples, but no use till now. None of them provided a real life example.

Hi @Surya_Narayana_Korivipadu,
Can you explain a little bit what do you mean?

Hi Pabilto. If we see the state activity, there’s a section called exit and I never used any activities in that section. Even the REframework exercises in RPA developer advanced course uses state activity, but those walkthrough documents didn’t talk about any activities to use inside exit section. When should I use activities in that section? In what scenarios it’ll be helpful.

However, I found an explanation of state machine in youtube and related it to traffic lights scenario. It’ll be more helpful if you can quote some real life examples, where state machines are used and more specifically entry, trigger, trigger condtions, trigger actions and exit section must be fully utilized in the workflows.

Out of the pocket, I can give you two simple examples.

  1. Resetting some variables that were used in the state before going further with a process.
  2. Closing applications that were used in the state.
1 Like

Do you know any real life scenarios where all the parts of the state activity can be utilized? Like I quoted traffic lights scenario. I’m just asking for a better understanding of state activity.

But what do you mean by real-life scenarios? The two I mentioned are quite commonly used in processes.

If we are automating traffic lights process, then we can use State machines. This is one example of a real life scenario. I didn’t find a need to use a state machine in any other projects I worked till now. I can build complete flow(entry, trigger, trigger condition, exit, trigger condition action) using sequence or flowchart too. But it’ll be helpful to understand the importance of state machine when we know the real life applications of it. That’s why I’m asking.

Maybe let me explain it from another perspective.

Re. 1st point - You have a variable that works as a counter for a loop activity. In your process, you have many loops where you will need to use a counter variable. Instead of declaring separate variables before each loop, you can do a loop in the state machine variable and reset a value of the counter on the exit. That means that your variable can be used in another loop starting from scratch.

Re. 2nd point - You have automation that needs to open an excel sheet, get some information and pass data to the Word application. You can build the whole process of opening an excel sheet and data grabbing in the state machine and use the close application activity in the exit part of it as excel is not needed anymore in the process. Then you can process with next steps where data will be provided to the word file.

In other words. The State Machine activity is useful to divide the project into separate sections. Of course, you can use for example the Invoke Workflow File activity for it. But the key here is to have a clear project that is not unnecessary nested and complicated.

Thank you pablito for the answer

1 Like