State machine transition arguments/variables

Do state machine transitions support the concept of a variable (or argument) by which you can pass data from one state to another? I was searching for an answer on this, but I did not get very far.

Of course, I can always use ‘global’ variables visible to the entire state machine.
Problem with that is that I need to carefully clean those variables up, so that leftovers from an earlier transition don’t confuse the next transition (in my app I would have a small table/dictionary with variable number of arguments of a command between states).

If transitions supported the concept of an argument, then I would not have to worry about cleaning it up, as it would be always specific to the last transition. It would also no pollute the list of variables seen on the top state machine level.

Yes buddy @zbalint
you can pass the arguments in any part of transition either as a condition or in the activities
within action part of transition…

in this case you can use arguments with direction IN/OUT that would make sure that the arguments can be used within the workflow and can be passed to other that would make sure the earlier transition wont getting confused with the next transition as the value can be used in either direction

Kindly try this and let know buddy
Cheers @zbalint

Apologies for being a bit slow here, but I do not understand.
To illustrate the issue and help others who may wonder about the same, I created a dummy state machine.

Can you augment the file please with one example on how the White Moves state can pass on to Black Moves a variable that is there only once, and is not globally visible in the whole state machine, just to the two said states, or only the receiving state?
So variable ‘whitesMove’ assigned to the transition argument, and read in Blacks Move state.
MyDummyWorkflow.xaml (19.9 KB)

You cannot do what you are intending, a variable cannot be confined to two separate states without being global. You cannot have a variable that is only visible to “White Moves” and “Black moves” but not visible to the other states.

Ideally your workflows would be designed to use as few global variables as possible, with none at all being the goal. If you find that multiple global variables are necessary to make your code work then consider reworking your design to fix that.

In other words, there is no ‘argument’ type construct that you can pass between states that would be unique to the transition. Either you have a local variable to the state, and the other state can’t have it, or you have a global variable, each state can read it, and you need to clean it up every time you come and go between states.

Yes. The only things that have “Arguments” are workflows. You can use those to handle data transition but states do not have arguments.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.