1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Power Automateの変数初期化エラーのメモ

Posted at

Power Automateの変数の初期化をしようとしたときに出たエラーです。

こんな感じでエラーでした。

{
 "title": "Node.jsのメモ",
 "tags": ["Node.js","JavaScript"]
}

こんな雰囲気のAPIから返ってきたAPIを処理する際に"tags"の中が配列でPA的に強制ループが発生するようなタイミングの話です。

CleanShot 2025-05-23 at 00.08.59.png

フローの保存がコード 'InvalidVariableInitialization' およびメッセージ 'The variable action '変数を初期化する' of type 'InitializeVariable' cannot be nested in an action of type 'For_each'.' で失敗しました。

ダメなパターン

そもそも仕様的にこの配置がNGな模様。たぶん。

CleanShot 2025-05-23 at 00.12.26.png

OKなパターン

変数の初期化をFor eachのループ外に定義して、その変数をループ内で上書きして使うという使い方

CleanShot 2025-05-23 at 00.13.50.png

まとめ

変数のスコープが柔軟さはない仕様っぽいです。世界観問題な気がする。

JSONなどで変数を保存するときは要注意。ループ使わないように式でどうにかできるときはそっちも良さそう

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?