You assign a value to your Out argument, a Message Box right after says it's filled, and a few activities later (or back in the parent workflow) it's Nothing. No error and no runtime warning. It's just empty.
This came up again on the UiPath Forum in Out param Nothing when leaving Do, and it's one of those bugs that makes you doubt Studio itself.
The cause
Most of the time, a variable and an argument share a name.
You've got out_Result in the Arguments panel, and somewhere along the way a variable called out_Result also got created, often scoped to a Sequence or a Do block. Inside that scope, your Assign writes to the variable. Outside it, you're reading the argument, which never got touched.
The Managing Arguments docs spell it out: if a variable and an argument have the same name, the variable is always the one used at runtime. The same goes for two variables in different scopes of one file. The inner scope wins.
How it sneaks in
For me it's usually Ctrl + K in the To field of an Assign. That shortcut creates a new variable, not an argument. So if you type the argument's name and hit Ctrl + K, you've just made a duplicate scoped to wherever you were.
(Ctrl + M is the one that creates an In argument.)
The fix
- Find the duplicate. Select the container (click the Do, Sequence or Try block, not just the root) and check the Variables panel for the argument's name. Delete the variable, keep the argument, then re-pick the argument in the Assign.
-
Let Workflow Analyzer catch it. Run Analyze File or Analyze Project from the Design ribbon. There are rules for exactly this:
-
ST-NMG-006Variable Overrides Argument -
ST-NMG-005Variable Overrides Variable
-
If you're on a team, set ST-NMG-006 to Error in the Workflow Analyzer settings. Then it shows up as an error in the Errors panel, which is a lot harder to scroll past.
-
Use direction prefixes on arguments only.
in_,out_,io_for arguments, never for variables. A variable calledout_Somethingthen looks wrong the moment you see it. - Assign the Out argument once. If the value gets built up across several scopes, work on a local variable and assign it to the Out argument once, at the end of the workflow:
' inside the scopes, work on a local variable
resultBuilder = resultBuilder & currentRow("Name").ToString
' last activity in the workflow
out_Result = resultBuilder
Docs
- Managing arguments: https://docs.uipath.com/studio/standalone/latest/user-guide/managing-arguments
- Managing variables: https://docs.uipath.com/studio/standalone/latest/user-guide/managing-variables
- ST-NMG-006 Variable Overrides Argument: https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-006
- ST-NMG-005 Variable Overrides Variable: https://docs.uipath.com/studio/standalone/latest/user-guide/st-nmg-005
- About Workflow Analyzer: https://docs.uipath.com/studio/standalone/latest/user-guide/about-workflow-analyzer
- Keyboard shortcuts: https://docs.uipath.com/studio/standalone/latest/user-guide/keyboard-shortcuts
Do you run Workflow Analyzer before every publish, or only when something breaks? Tell me in the original forum thread, that's where the discussion is: https://forum.uipath.com/t/uipath-pitfall-of-the-week-4-a-variable-with-the-same-name-as-your-argument/5786751
Originally posted on the UiPath Forum: https://forum.uipath.com/t/uipath-pitfall-of-the-week-4-a-variable-with-the-same-name-as-your-argument/5786751
Prefer to watch it? Here is the video version: UiPath Studio: Out Argument Is Nothing After Do + Agent LLM HTTP 403.
I post short UiPath fix videos from real forum questions on my YouTube channel, RPA Simplified.
Top comments (0)