Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

UiPath Pitfall #4: A Variable With the Same Name as Your Argument

说明与用途

问题:Out 参数在 Do 块后变为 Nothing,原因是同名变量。解决方案:删除重复变量,使用工作流分析器,并为参数加前缀。

问题

An Out argument receives a value, but after exiting a Do block it becomes Nothing because a variable with the same name shadows the argument.

结果

The Out argument retains its value after the Do block once the duplicate variable is removed and the workflow is analyzed.

工作流

  • Identify that an Out argument is unexpectedly Nothing after a Do block.
  • Check the Variables panel for a variable named the same as the argument within the Do block.
  • Delete the duplicate variable and keep the argument.
  • Re-select the argument in the Assign activity.
  • Run Workflow Analyzer to catch Variable Overrides Argument (ST‑NMG‑006).
  • Set ST‑NMG‑006 to Error to surface the issue immediately.
  • Use direction prefixes (in_, out_, io_) only for arguments to avoid confusion.
  • Assign the Out argument once at the end of the workflow, using a local variable for intermediate calculations.

证据

Most of the time, a variable and an argument share a name.

来源

If a variable and an argument have the same name, the variable is always the one used at runtime.

来源

Ctrl + K in the To field of an Assign creates a new variable, not an argument.

来源

Run Analyze File or Analyze Project from the Design ribbon. There are rules for exactly this: ST‑NMG‑006 Variable Overrides Argument.

来源

  • 记录日期: 2026-11-01T02:44:02.781Z