Does this flow look weird to you?
One common situation when people are taking the first steps in this awesome world of OutSystems is trying to use data that are out of scope.
In this article, we are going to explore some situations where maybe you will not get the results that you want!
#1 Splitting and converging
You can see an example of this is the situation shown in the image on the left.
If all the possible routes begin at the Start node, all of them need to pass through the ActionBefore. The output of that action will be available throughout the whole flow.
But if you try to use the output of the ActionLeft or ActionRight nodes, you won’t be able to use it after the flows converge on ActionAfter. And the reason is simple: we don’t know if that data will be available.
If you are coming from the left branch and then in the AssignCommon you have “var = ActionRight.Out”, the assign is trying to get a value that might be empty, and we don’t want to have an ambiguous situation like that in our action.
It is particularly important to have this in mind at Preparation. If you split the Preparation flow, add there a SQL query or an aggregate, and then try to use that data source on a widget, both will be available but the results might, once again, be empty.
#2 Debug without using the data
We are trying to fill a list using ListAppend, but using debug, we see that the previous elements of the list are being set to the default value, and only the last one is being kept.
Actually, everything is fine. If this list variable is not being used anywhere, the debugger doesn’t feel the need to worry about that data. This is called optimization. In a platform as huge as OutSystems, it needs to understand what data is important to spend resources on.
Don’t get tricked by the debugger :)
#3 Outside the Flow -> Outside the Scope
You may not find some data available if the node isn’t in a specific place of the flow.
In this example, if the assign node is not after the CreateUser, you can’t access the output of it. Be sure that you put the nodes in the correct place first!
#4 Don’t Make Shy Flows
A shy flow is a flow where you hide the logic.
One assign should just do one thing, the result could be the same, but your action will be easier to read!
There are many reasons for you to get different results for what you want. Keep calm, debug, and don’t be afraid to redo something.
Don’t be afraid to use the forums in the Outsystems Community page. There you may get a reply from one of ITUp’s MVPs, and we have four :)