
[Power Automate] 便利な関数など
Power Automate で string を短くする方法
Apply Eachなどで複数のStringを「,」などで付け足していて、最後に付け足したStringにもあって不便な時がある。
substring(variables('stringVariable'),0,sub(length(variables('stringVariable')),2))
上記のコードは「stringVariable」を2文字短くする。
Append String Variable で「,」や「/」などを短くできる。
「Scope」を使って「Success」と「Fail」を扱う
「Scope」の中に大事なステップをいれて、そのうちどれかが失敗したときにエラーをキャッチできる。
以下のように設定することで達成できる
PowerAppsから複数の変数を楽にPower Automate に渡す
1. JSONを使う
2. JSONで設定した変数がそのまま設定できる
下記の関数をPowerAppsのボタンなどに加えて、messageDataJSONなどの変数にJSONを書き加える
Set(
messageDataJSON,
JSON(
{
userId:DataCardValue1.Id,
country:DataCardValue2.Text,
variable:DataCardValue3.Text
},
JSONFormat.IndentFour
)
);
そしたら、messageDataJSONの変数をAutomateに伝える
'Power Automate Name'.Run(messageDataJSON)
Automateでの受け取り方は以下の通り
Schemaが必要
Schemaの例:
{
"type": "object",
"properties": {
"userId": {
"type": "string"
},
"country": {
"type": "string"
},
"variable2": {
"type": "string"
}
}
}