検査場所に階層を追加する

検査サンプル アプリを使用すると、ユーザーはアプリで検査を作成して実行できます。 検査を実行、管理、レビューするために、ペルソナごとに 3 つのアプリがあります。 3 つのアプリには、検査、検査の管理、検査のレビューがあります。

デフォルトでは、検査アプリは単一の店舗向けに設計されています。 では、複数の店舗で検査を実行する場合はどうなりますか? アプリに店舗のテーブルを追加してユーザーが検査を実行している店舗を選択できるようにし、どの店舗で検査が実行されたか追跡できるようにします。

この記事では、アプリを更新して店舗の階層を追加し、さまざまな店舗に対して検査を実行できるようにする方法を説明します。

このビデオでは、検査位置に階層を追加する方法について説明します:

前提条件

このレッスンを完了するには、選択した Microsoft 365 サブスクリプションの一部として提供される Microsoft Teams へのログイン機能と、Teams 用の検査サンプル アプリをインストールしておく必要があります。 このアプリは https://aka.ms/TeamsInspection からインストールできます。

検査アプリを編集する

  1. Teams にログインして、左ペインの Power Apps アプリを右クリックし、ポップ アウト アプリ を選択します。

  2. 上のリボンから ビルド を選択します。

  3. 検査アプリをインストールしたチームを選択します。

  4. 検査を選択して Power Apps Studio のアプリを開きます。

Store という新しいテーブルを追加します

  1. 左ペインから、データ を選択します。

  2. データの追加 を選択します。

  3. 新しいテーブルの作成 を選択します。

  4. テーブル名をに「Store」と入力し、作成 を選択します。

  5. 列の追加 ボタンを選択し、新しい列を挿入します。

  6. 「店舗番号」として列の名前を入力し、作成 を選択します。

  7. テーブルにいくつかのサンプル レコードを追加し、閉じる を選択します。

    店舗テーブル

品目の更新画面

品目画面で検査を表示できるように、以下のコントロールの式を更新します。

  1. ツリー ビューlblIssues_Header のラベルを検索して選択します。

  2. Text プロパティを選択します。

  3. 式の次の部分を置き換えします。

    式セクションを削除します:

    With(
    {
        varDefault: "Issues reported (" & CountRows(
            Filter(
                locSelectedInspection,
                Outcome = 'Inspection Outcome'.Issue
            )
        ) & ")",
        varOOBTextId: "_translateVariable_IssuesHeader",
        varParam0: "(" & CountRows(
            Filter(
                locSelectedInspection,
                Outcome = 'Inspection Outcome'.Issue
            )
        ) & ")"
    },
    

    式セクションを追加します:

    With(
    {
        varDefault: "Issues reported (" & CountRows(
            Filter(
                galInspections.Selected.'Area Inspection Steps',
                Outcome = 'Inspection Outcome'.Issue
            ).'Area Inspection Step'
        ) & ")",
        varOOBTextId: "_translateVariable_IssuesHeader",
        varParam0: "(" & CountRows(
            Filter(
                galInspections.Selected.'Area Inspection Steps',
                Outcome = 'Inspection Outcome'.Issue
            ).'Area Inspection Step'
        ) & ")"
    },
    
  4. ツリー ビューlblNoIssues_Header のラベルを検索して選択します。

  5. Text プロパティを選択します。

  6. 式の次の部分を置き換えします。

    式セクションを削除します:

    With(
    {
        varDefault: "No issues (" & CountRows(
            Filter(
                locSelectedInspection,
                Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
            )
        ) & ")",
        varOOBTextId: "_translateVariable_NoIssuesHeader",
        varParam0: "(" & CountRows(
            Filter(
                locSelectedInspection,
                Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
            )
        ) & ")"
    },
    

    式セクションを追加します:

    With(
    {
        varDefault: "No issues (" & CountRows(
            Filter(
                galInspections.Selected.'Area Inspection Steps',
                Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
            ).'Area Inspection Step'
        ) & ")",
        varOOBTextId: "_translateVariable_NoIssuesHeader",
        varParam0: "(" & CountRows(
            Filter(
                galInspections.Selected.'Area Inspection Steps',
                Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
            ).'Area Inspection Step'
        ) & ")"
    },
    
  7. ツリー ビューgalNoIssuesAttachments のギャラリーを検索して選択します。

  8. Items プロパティを選択します。

  9. 式の次の部分を置き換えします。

    式セクションを削除します:

    ThisItem.'Area Inspection Images'
    

    式セクションを追加します:

    LookUp('Area Inspection Steps','Area Inspection Step'=ThisItem.'Area Inspection Step').'Area Inspection Images'
    
  10. ツリー ビューgalIssuesAttachments のギャラリーを検索して選択します。

  11. Items プロパティを選択します。

  12. 式の次の部分を置き換えします。

    式セクションを削除します:

    ThisItem.'Area Inspection Images'
    

    式セクションを追加します:

    LookUp('Area Inspection Steps','Area Inspection Step'=ThisItem.'Area Inspection Step').'Area Inspection Images'
    
  13. ツリー ビューgalNoIssues のギャラリーを検索して選択します。

  14. Items プロパティを選択します。

  15. 式の次の部分を置き換えします。

    式セクションを削除します:

    Sort(
    Filter(
        locSelectedInspection,
        Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
    ),
    Value(Sequence),
    Ascending
    )
    

    式セクションを追加します:

    Sort(
    Filter(
        galInspections.Selected.'Area Inspection Steps',
        Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
    ),
    Sequence,
    Ascending
    )
    
  16. ツリー ビューgalIssues のギャラリーを検索して選択します。

  17. Items プロパティを選択します。

  18. 式の次の部分を置き換えします。

    式セクションを削除します:

    Sort(
    Filter(
        locSelectedInspection,
        Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
    ),
    Value(Sequence),
    Ascending
    )
    

    式セクションを追加します:

    Sort(
    Filter(
        galInspections.Selected.'Area Inspection Steps',
        Outcome = 'Inspection Outcome'.OK || Outcome = 'Inspection Outcome'.'N/A'
    ),
    Sequence,
    Ascending
    )
    

エリア検査テーブルに店舗をキャプチャする列を追加します

  1. 左側のナビゲーション メニューから データ を選択します。

  2. エリア検査 テーブルを見つけて、... (省略記号) を選択します。

  3. データの編集 を選択します。

  4. 列の追加 を選択し、テーブル名を "Store"、タイプを "Lookup"、関連テーブルを "Store" と入力します。

  5. 作成 を選択します。

  6. 閉じる を選択します。

  1. 左ペインからツリー ビューを選択します。

  2. ツリー ビューの画面で、新規 を選択します。

  3. 空白のレイアウトを選択します。

  4. 画面の名前を "StoreSelectionScreen" に変更します。

  5. Fill プロパティを gblAppStyles.Background.Fill に更新します。

  6. 挿入 を選択して、ギャラリーに新しい画面を追加します。

  7. データ ソースとして、店舗 を選択します。

  8. ギャラリーの名前を "StoresGallery" に変更します。

  9. ギャラリーに次の StoresGallery プロパティを設定します。

    プロパティ
    テンプレート サイズ 108
    フォント サイズ 20
    Title4 の高さ 45
    ラベル Subtitle4 のフォントサイズ 18
    ラベル Subtitle4 の高さ 45
  10. アイテム 画面に移動し、画面のトップから 戻る ボタンをコピーします。

  11. コピーしたボタンを新しい画面に貼り付けます。

  12. 前の手順を繰り返して、ラベル lblIndividualAreasHeader を場所としてテキストを読み出しているアイテム画面から、新しい画面にコピーします。

  13. ラベルの Y プロパティを btnBackToHome_1.Y+btnBackToHome_1.Height に設定します。

  14. 次のギャラリーのプロパティに StoresGallery を設定します。

    プロパティ
    btnBackToHome_1.Height+lblIndividualAreasHeader_1.Height
    高さ Parent.Height-btnBackToHome_1.Height- lblIndividualAreasHeader_1.Height
    OnSelect Set(gblSelectedStore,ThisItem);Navigate('Items Screen')
  15. アイテムに移動して、トップの ホームに戻る ボタンを選択し、次のボタンのプロパティを更新します。

    プロパティ 価値
    OnSelect Navigate(StoreSelectionScreen, ScreenTransition.Fade)
    テキスト "Back to Store Selection"
  16. チェックリスト手順 画面に移動します。

  17. 画面の OnVisible プロパティを選択し、エリア検査 アプリを更新するパッチ関数を更新して、数式のストア値を追加します。

    , Store: gblSelectedStore
    

    パッチ機能に店舗を追加

ようこそ画面のナビゲーションを更新する

  1. ツリー ビューから、ようこそ画面を選択します。

  2. 検査を実行する (btnInspect) ボタンを選択します。

  3. ボタンの OnSelect プロパティから ナビゲート 機能を更新して、アイテム 画面ではなく StoreSelectionScreen 画面に移動し、残りの数式は変更しません。

    Navigate(
    StoreSelectionScreen,
    ScreenTransition.Fade
    );
    

    店舗選択画面に移動します

検査アプリを発行する

検査アプリの変更がすべて完了しました。 これで、右上の Teams に公開 ボタンを選択してアプリを公開できます。

Teams に公開

検査アプリのレビューを編集する

  1. Teams で Power Apps を開きます。

  2. トップのリボンから ビルド タブを選択します。

  3. 検査アプリをインストールしたチームを選択します。

  4. エディターでアプリを開いて、検査のレビュー を選択します。

  5. 左ペインから、データ を選択します。

  6. 追加 データを選択して、店舗 テーブルをこのアプリのデータベースに追加します。

  7. エリア検査 テーブルを最新の情報に更新することで、店舗 の列がテーブルに表示されます。

検査で店舗を表示するためのラベルを追加します

  1. ツリー ビューを開き、アイテム画面を選択します。

  2. グループ grpInspectionSteps の下で、"lblInspection_SubmissionDetails" というラベルを選択して、その テキスト プロパティを次の数式に更新します。

    If(
        DateDiff(
            Date(
                Year(galInspections.Selected.createdon),
                Month(galInspections.Selected.createdon),
                Day(galInspections.Selected.createdon)
                ),
            Today(),
            Days
                ) = 0,
    If(
        DateDiff(
            Date(
                Year(galInspections.Selected.createdon),
                Month(galInspections.Selected.createdon),
                Day(galInspections.Selected.createdon)
                ),
            Today(),
            Hours
                ) > 0,
        galInspections.Selected.Store.Name & " | Submitted by " &
        galInspections.Selected.createdby.'Full Name' & ", " & DateDiff(
        Date(
            Year(galInspections.Selected.createdon),
            Month(galInspections.Selected.createdon),
            Day(galInspections.Selected.createdon)
            ),
        Today(),
        Hours
                ) & " hrs ago",
    If(
        DateDiff(
            Date(
                Year(galInspections.Selected.createdon),
                Month(galInspections.Selected.createdon),
                Day(galInspections.Selected.createdon)
                ),
        Today(),
        Hours
        ) = 0,
    //"minutes ago"
    galInspections.Selected.Store.Name & " | Submitted by " &
    galInspections.Selected.createdby.'Full Name' & ", minutes ago"
    ,
    If(
        DateDiff(
        Date(
            Year(galInspections.Selected.createdon),
        Month(galInspections.Selected.createdon),
        Day(galInspections.Selected.createdon)
            ),
        Today(),
        Days
        ) = 1,
        //"yesterday",
        galInspections.Selected.Store.Name & " | Submitted by " &
        galInspections.Selected.createdby.'Full Name' & ", yesterday",
        galInspections.Selected.Store.Name & " | Submitted by " &
        galInspections.Selected.createdby.'Full Name' & ", " & DateDiff(
        Date(
            Year(galInspections.Selected.createdon),
            Month(galInspections.Selected.createdon),
            Day(galInspections.Selected.createdon)
            ),
        Today(),
        Days
        ) & " days ago"
    )
    )
    )
    )
    

アプリをテストする

  1. インストールされているチームで検査アプリを開きます。

  2. Studio 内で実行している場合は、ツリー ビューからようこそ画面を選択し、プレビュー を選択します。

  3. 検査実行 を選択します。

  4. 店舗選択画面が開くことを確認します。

  5. 店舗を選択します。 次の画面はアイテム画面になります。

  6. 場所を選択します。

  7. 次の画面で食品検査チェックリストを選択します。

  8. 検査開始 ボタンを選択します。

  9. 検査の一部である質問に答えてから、検査のレビュー を選択します。

  10. 次の画面で 検査を提出する を選択します。

  11. 次に、インストールされているチームのトップにある 検査のレビュー タブを選択して、検査のレビュー アプリにログインします。

  12. 以前に選択した場所を選択して、実行された検査のリストを表示します。

  13. 以前に提出された検査を選択します。

  14. 画面には店舗名が表示されます。

    ロケーション画面に表示されている店舗

関連項目

注意

ドキュメントの言語設定についてお聞かせください。 簡単な調査を行います。 (この調査は英語です)

この調査には約 7 分かかります。 個人データは収集されません (プライバシー ステートメント)。