You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Automate Desktop中变量引用无法解析的技术求助

Power Automate桌面版脚本变量解析问题解决

问题重现

在Power Automate桌面版脚本中尝试拼接流变量时,变量被识别为字面量而非实际值:

SET sample TO $fx'"hello this is a test of a string"'
SET NewVar2 TO $fx'"Hello %sample%"'

当前结果:Hello %sample%
期望结果:

Hello hello this is a test of a string

尝试过Hello + %sample%、Hello '%sample%'等写法,均未生效。

解决方案

Power Automate桌面版的脚本模式和UI动作的变量引用规则不同,正确的变量引用和字符串拼接方式如下:

方式1:直接脚本赋值(无需$fx)

脚本模式下直接使用变量名,用&进行字符串拼接:

SET sample TO "hello this is a test of a string"
SET NewVar2 TO "Hello " & sample

方式2:使用$fx表达式

如果需要用$fx包裹表达式,内部需遵循Power Automate表达式语法,直接引用变量名并用&拼接:

SET sample TO $fx'"hello this is a test of a string"'
SET NewVar2 TO $fx'"Hello " & sample'

关键说明

  • 脚本模式中**不能用%变量名%**引用变量,这是UI动作里的语法,脚本里直接写变量名即可。
  • 脚本内字符串拼接必须用&,而非+(+在Power Automate表达式中多用于数值运算)。

内容的提问来源于stack exchange,提问作者Glen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 05:12:11