LoginSignup
4
2

More than 3 years have passed since last update.

SharePoint リストの列の書式設定でリンクを活性にする

Posted at

はじめに

SharePoint リストには、JSON 形式で列の書式設定をカスタマイズする機能があります。
列の書式設定で SharePoint をカスタマイズする
公式ドキュメントにいろいろ書いていますが、読むのが面倒な方のために「1行テキスト」型の列をリンク化する方法をご紹介します。

1つの列の値を使ってリンク化

リンク化したい列の列名を右クリックし「列の設定>この列の書式設定」を開いてください。
ここに JSON を貼り付ければ設定完了です。

image.png

JSON はこちらです。

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "@currentField",
    "target": "_blank"
  }
}

書式を設定しようとしている列の値を @currentField で参照しています。

他の列の値を使ってリンク化

発展形として、別の列の値と組み合わせてリンクを生成することもできます。
以下では URL と検索ワードを組み合わせて検索結果ページのリンクを作成しています。

image.png

JSON はこちらです。

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "href": "=if([$value]=='https://www.yahoo.co.jp/', 'https://search.yahoo.co.jp/search?p=' + @currentField, 'https://www.google.com/search?q=' + @currentField)",
    "target": "_blank"
  }
}

Excel ライクな if 文が書けます。
また [$列名] で別の列の値を参照できます(この場合は「URL」列)。
列名は、画面に表示されている値ではなく、その列の値でフィルターを設定した際の URL の FilterField1= の後ろの値です。

image.png

以上

4
2
8

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
4
2