When to use Variables

When to use Variables

  
I know this one is easy and really basic... :-)
Any time I build an action, I'd like to be sure to use the correct variables.
I can use an "Input Variable" any time, assign it a value and use it in next action or step. This is possible and works. However I suppose this is not a good way to use variables.
My main doubt is when and in what conditions to use "Local", "Input" and "Output" variables. Where should I use, or not, a Local Variable instead of an Input or Output Variable? Where should I use an Output Variable instead of an Input Variable, or an Input instead of an Output? Or any of those instead of a Local?
Input parameters define data passed inside an action or screen that will be used to compute its results. They should be used whenever the actions or screens depend on external data. As example, consider a screen that is used to edit a user: this screen should have a screen input parameter with the user Id so that the screen preparation could get user data.
Output parameters are used to return actions’ computed values. They should be used whenever an action must return some data. (Please note that you can only define output parameters in user-defined actions). Imagine, as example, that you should determine user’s age. You could create an action to perform this operation: it would have an input parameter containing the user birth date and an output parameter containing the actual user age.
The local variables can be used in every other situation, typically as a repository for temporary data. You should use them whenever you don’t have external dependencies for the data being manipulated. Consider a user creation: create a local variable of type record and record definition User; you can then fill in all fields and send to database the new user.
To sum up, notice that when input and output parameters are changed they affect all action’s instances. For this reason, you should only use them when you actually need external data. With local variables, the dependencies only exist in action definition which will not affect the action usage.
Thanks very much, Claudia, that helped me understand.