DataverseとD365BCを連携された状態で、Dataverseのテーブルレコードの変更を素早く検知してBCに反映させる仕組みが追加されたので試してみます。
元ネタは以下です。2022 Release Wave 2のリリースノートです。
・英語版: Use a Power Automate flow to notify Business Central of Dataverse entity changes
・日本語版: Power Automate フローを使用して Dataverse エンティティの変更を Business Central に通知する
前提として、B365BCでDataverseの連携を設定しておく必要があります。設定自体は以下の画面の左上の”Assisted Setup”の画面から実行できますが今回は省略します。DataverseとBCの接続は”Data Synchronization”方式と”Virtual Table”の2方式をこの画面で指定できますが、必要なのは”Data Synchronization”方式です。
![](/wp-content/uploads/2022/12/01_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
Dataverse側の環境は上述のDataverse Connection Setupの設定前に用意しておきます。今回、実験で使用するのはAccountテーブルとContactテーブルです。
![](/wp-content/uploads/2022/12/02_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
Dataverseのレコード変更をBCに通知するにはPower Automateを使用します。上述のDataverse環境でPower Automateのテンプレートから”Business Central”というキーワードで検索するといろいろと出てきます。
![](/wp-content/uploads/2022/12/03_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
キーワードに “Notify”を追加するとテンプレートが3つ出てきます。変更を検知するDataverseのテーブルとして”Account”と”Contact”と”Currency”の3つがテンプレート化されています。(AccountとContactはわかるけど、何でCurrencyなん?ってのは思いますがw) 実験はまず一番左にある”Account”のテンプレートを使いましょう。
![](/wp-content/uploads/2022/12/04_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
接続はサインインしたうえで”Continue”をクリック。
![](/wp-content/uploads/2022/12/05_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
テンプレートが展開されます。詳しい解説は後でやりますがザックリいうと「Accountテーブルの変更を検知したら、変更したユーザーIDをチェックしてBC関連ならBCのレコードに反映する」というフローです。
![](/wp-content/uploads/2022/12/06_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
Dataverseのコネクタを開きます。特に設定追加すべき項目はありません。
![](/wp-content/uploads/2022/12/07_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x877.png)
BCのコネクタを開きます。対象のEnvironmentとCompanyは指定が必要です。指定したら保存してテスト実行。
![](/wp-content/uploads/2022/12/08_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x733.png)
マニュアル実行。
![](/wp-content/uploads/2022/12/09_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
実験開始です。DataverseのAccountのレコードを変更します。例えばAccount Nameを変更してみます。(この時、レコードの”RelationshipTypeが”Customer”のレコードを選んで変更します。)
![](/wp-content/uploads/2022/12/10_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
クラウドフローが実行され、、
![](/wp-content/uploads/2022/12/11_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
BCのCustomerの対応するレコードが変更されました。成功です。(なお、このレコードは事前にDataverseの該当レコードとカプリングしておく必要があります。)
![](/wp-content/uploads/2022/12/12_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
2つ目のテンプレート、Contactでも試してみましょう。
![](/wp-content/uploads/2022/12/13_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
テンプレートから作成したクラウドフローにBCのEnvironment名、Company名を設定してテスト実行したのち、Dataverseの”Contact”テーブルのレコードを変更します。
![](/wp-content/uploads/2022/12/14_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
するとクラウドフローが実行され、、
![](/wp-content/uploads/2022/12/15_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
BCのContactの対応レコードが変更されました。成功です。(これも事前にDataverseのContactのレコードとカプリングしておく必要あり。)
![](/wp-content/uploads/2022/12/17_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
別の実験です。Accountテーブルに戻り、新規でレコードを登録します。
![](/wp-content/uploads/2022/12/18_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
BC側でレコードは追加されません。。
![](/wp-content/uploads/2022/12/19_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
新規登録するには”Account – Dataverse”テーブルの一覧画面から該当レコードを選択して”Create in Business Central”をクリックします。
![](/wp-content/uploads/2022/12/20_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
すると、レコードが作成されます。
![](/wp-content/uploads/2022/12/21_D365BC-Use-Power-Automate-Notify-Dataverse-Entity-Changes-1024x576.png)
ここまでは冒頭に紹介したDocs見てそのまま実施すれば良いだけです。次回はこの仕組みを解析したいと思います。
1件のコメント