Sharepointのリストで親子関係のデータを1つのフォームに表示したい時、
参照関係の列を追加して、子リストをソースとして選択後、複数選択可能にしたらよい。
また、一緒に表示したい追加の列も選択可能
見た目は下記のようになる。
リンクをクリックすると、なんとクラシック表示のダイアログが表示されてしまう。
foreach構文を利用してアイテムクリック時別タブで開けるように変更する。
イメージ:
コード:
{
"$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種類のみ
本当は別のページに飛ばして見栄えのいい画面にしたかったが
ページ内のリストプロパティパーツにパラメータを渡す方法がないのが非常に残念。