0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Sharepoint] リストの参照タイプの列を繰り返し処理する。

Posted at

Sharepointのリストで親子関係のデータを1つのフォームに表示したい時、
参照関係の列を追加して、子リストをソースとして選択後、複数選択可能にしたらよい。
また、一緒に表示したい追加の列も選択可能

image.png

{F9E0A809-375B-4AEF-9CF3-CD1DEE0171E4}.png

見た目は下記のようになる。

{23BC5DA8-F9BE-451D-A22A-84C583AFDC4D}.png

リンクをクリックすると、なんとクラシック表示のダイアログが表示されてしまう。

image.png

foreach構文を利用してアイテムクリック時別タブで開けるように変更する。
イメージ:
{D9596099-9052-43A1-924C-3B2DD88CB060}.png

コード:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "margin": "5px 0px"
  },
  "children": [
    {
      "elmType": "div",
      "style": {
        "display": "flex",
        "flex-direction": "column",
        "justify-content": "flex-start",
        "flex-wrap": "wrap"
      },
      "children": [
        {
          "elmType": "div",
          "forEach": "item in @currentField",
          "style": {
            "margin": "3px 0px",
            "display": "flex",
            "flex-direction": "row",
            "align-items": "center"
          },
          "children": [
            {
              "elmType": "div",
              "txtContent": "=loopIndex('item')+1 + '.'",
              "style": {
                "width": "18px"
              }
            },
            {
              "elmType": "a",
              "txtContent": "[$item.lookupValue]",
              "attributes": {
                "target": "_blank",
                "href": {
                  "operator": "+",
                  "operands": [
                    "https://<tenant>.sharepoint.com/sites/<sitename>/web/<subsitename>/Lists/<listname>/DispForm.aspx?ID=",
                    "[$item.lookupId]"
                  ]
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

※参照関係で取得可能な値は「lookupId、lookupValue」の2種類のみ

本当は別のページに飛ばして見栄えのいい画面にしたかったが
ページ内のリストプロパティパーツにパラメータを渡す方法がないのが非常に残念。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?