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
相关产品推荐
相关产品推荐

