プロジェクトでは、行政地域や従業員、製品カテゴリーなど、階層的なデータを使用することがあります。dynamics 365のAccountエンティティは、「Account Hierarchy」という階層の設定がout-of-boxとして既に実装されています。
今回は「Account Hierarchy」にあるHierarchy Settingのデモを行い、階層設定に対する理解を深めてきたいです。
Microsoftのドキュメントに参考していました。良ければこちらのオフィシャルサイトにも確認して頂ければと思います。
・階層データのクエリの実行 (Microsoft Dataverse) – Power Apps | Microsoft Docs
・Dynamics 365 Customer Engagement (on-premises) での階層データのビジュアル化 | Microsoft Docs

デモのために、次のように行政地域のエンティティを作成し、フィールドの1つをこのエンティティへのルックアップ・フィールドとします。以下は詳細手順を示しています。
まず、ソリューションを新たに作成し、その下にエンティティを新規作成します。

エンティティの中で、フィールドを新規作成します。

表示名や名前などの基本情報を入力し、種類は「検索(Lookup)」を選択し、ターゲットレコードの種類は先ほど作ったエンティティの表示名「行政地域Demo」と紐づいています。

そして、エンティティの階層設定に、1つの階層を新規作成します。

「関係を階層に対して有効としてマークします」をクリック、先ほど作ったフィールドをチェック入れて、「階層としてマーク」を選択します。

保存が出来たら、下記の通りに階層設定が確認出来ています。

階層設定は以上で終わりました。実現するロジックは、行政地域(都道府県)の階層を表示することです。
次はフロント側に戻ってダミーデータのレコードを作成します。

東京都下にある行政都市を作成しました。
階層設定を行うことによって、都下の行政都市と東京都の関係が構築出来ました。


階層設定により、レコードの操作や検索などが容易になります。FetchXMLを使えば、高度な検索も可能。
下記はD365開発者向けの情報です。検索の条件および返した結果を説明するドキュメントです。
FetchXML | ConditionOperator | Description |
above | Above | Returns all records in referenced record’s hierarchical ancestry line. |
eq-or-above | AboveOrEqual | Returns the referenced record and all records above it in the hierarchy. |
under | Under | Returns all child records below the referenced record in the hierarchy |
eq-or-under | UnderOrEqual | Returns the referenced record and all child records below it in the hierarchy |
not-under | NotUnder | Returns all records not below the referenced record in the hierarchy |
eq-useroruserhierarchy | OwnedByMeOrMyReports | When hierarchical security models are used, Equals current user or user’s reporting hierarchy |
eq-useroruserhierarchyandteams | OwnedByMeOrMyReportsAndTeams | When hierarchical security models are used, Equals current user and user’s teams, or user’s reporting hierarchy and their teams |
コメント