---
title: "【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)"
url: "https://www.geekfujiwara.com/tech/d365/837/"
author: ギークフジワラ
published: "2019-05-15T11:40:23+00:00"
updated: "2026-10-23T21:27:50+00:00"
categories: [Dynamics 365, Power Platform]
tags: [Dynamics 365, Finance and Operations, Microsoft, Power Automate, Power Platform, PowerApps]
description: "以前、Dynamics 365 Finance, Supply Chain Management (旧称 Finance and Operations)の画面にPowerApps をかぶせて簡易発注画面を作る試みをしました。 今回はそのPo…"
---

# 【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)

以前、Dynamics 365 Finance, Supply Chain Management  (旧称 Finance and Operations)の画面にPowerApps をかぶせて簡易発注画面を作る試みをしました。

\[sc\_blogcard url="https://www.geekfujiwara.com/tech/d365/753/"\]

今回はそのPower Apps を少しだけ改善してみましょうという試みです。

改善内容としては、採番された発注書番号を取得してPowerApps 画面に表示してみましょうというものです。

これが出来たら、確かに発注書が作成された&amp;何番の発注書が作成されたか分かって便利です。

というわけで、簡単に実装できますので早速紹介して行きます。

## PowerApps 関数の説明

Power Automateから取得した値を変数に保存します。用途によって、以下1〜2を使い分けます。

### そのスクリーンでのみ利用する一時変数にFlowから取得した値を格納する場合

\[codebox title="コード"\]

```
UpdateContext({‘変数(ここで初めて宣言します)’: ‘Flow名’.Run()})
```

\[/codebox\]

### 全スクリーンで利用可能なグローバル変数にFlowから取得した値を格納する

\[codebox title="コード"\]

```
Set(‘変数(ここで初めて宣言します)’, ‘Flow名’.Run())
```

\[/codebox\]

## では早速実装する

Power Automateで作成した変数にFOから取得した発注書番号を格納します。

### 以前作成したFlowにアクションを追加する

Power AppsコネクターのRespond to PowerApps アクションを利用します。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-1.png)</figure>今回データ型はテキストである為、テキストを選択します。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-2.png)</figure>変数に名前をつけ、作成した発注書番号を格納します。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-3.png)</figure><div class="information-box common-icon-box">ここで定義した変数名 (ここではCreatedPurchaseOrderNumber) は大文字が入っていたとしても、PowerApps で呼び出す際は全て小文字で記述する必要があることにご注意ください。</div>保存して終了します。

### Power Automateの更新

PowerApps 側で、Flowの接続をもう一度行なって更新します。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-4.png)</figure>### Power Automateで取得したデータを利用する

PowerApps 側で、UpdateContextあるいはSet関数でFlowのデータを取得する関数を記述します。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-5-1024x132.png)</figure><div class="memo-box common-icon-box">今回はスクリーンをまたがるのでグローバル変数としました。データが残るのが気になる場合、完了のチェックボタンを押せば画面が戻るようにし、同時にグローバル変数もリセットされるようにすると良いでしょう。</div><div></div>成功スクリーンを編集してみると、こんな感じに使うことができます。

<figure class="wp-block-image size-large">![【D365+PowerApps】Power Automateで取得したデータをPower Appsに返す (Easy PO改善)](https://www.geekfujiwara.com/wp-content/uploads/2019/05/gphotos-837-6.png)</figure>いかがでしたでしょうか。

ご参考になれば幸いです。
