1

Can I know why the title and modified by not showing? also the box shadow is not working?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "height": "120",
  "width": "400",
  "hideSelection": true,
  "formatter": {
    "elmType": "div",
    "style": {
      "background-color": "white",
      "box-shadow": "0 3px 10px white",
      "display": "flex",
      "position": "relative",
      "font-size": "0.8rem"
    },
    "children": [
      {
        "elmType": "div",
        "children": [
          {
            "elmType": "a",
            "attributes": {
              "target": "_blank",
              "href": "https://images.unsplash.com/photo-1534796636912-3b95b3ab5986?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80"
            },
            "children": [
              {
                "elmType": "filepreview",
                "style": {
                  "width": "150px",
                  "height": "120px"
                },
                "attributes": {
                  "src": "@thumbnail.512x432",
                  "alt": "Image"
                }
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "children": [
          {
            "elmType": "div",
            "style": {
              "font-weight": "bold",
              "padding": "15px"
            },
            "txtContent": "Hai [$Name]"
          },
          {
            "elmType": "div",
            "style": {
              "color": "RGBA(155, 155, 155, 1)",
              "position": "absolute",
              "bottom": "0",
              "padding": "15px"
            },
            "txtContent": "Uploaded on [$Modified]"
          }
        ]
      }
    ]
  }
}

1 Answer 1

0

You cannot directly add statis text (like 'Hai') and dynamic content from SharePoint column in txtContent. You have to write the expression to combine these like:

"txtContent": "='Hai ' + [$Name]"

Full example:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "height": "120",
  "width": "400",
  "hideSelection": true,
  "formatter": {
    "elmType": "div",
    "style": {
      "background-color": "white",
      "box-shadow": "0 3px 10px white",
      "display": "flex",
      "position": "relative",
      "font-size": "0.8rem"
    },
    "children": [
      {
        "elmType": "div",
        "children": [
          {
            "elmType": "a",
            "attributes": {
              "target": "_blank",
              "href": "https://images.unsplash.com/photo-1534796636912-3b95b3ab5986?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80"
            },
            "children": [
              {
                "elmType": "filepreview",
                "style": {
                  "width": "150px",
                  "height": "120px"
                },
                "attributes": {
                  "src": "@thumbnail.512x432",
                  "alt": "Image"
                }
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "children": [
          {
            "elmType": "div",
            "style": {
              "font-weight": "bold",
              "padding": "15px"
            },
            "txtContent": "='Hai ' + [$Name]"
          },
          {
            "elmType": "div",
            "style": {
              "color": "RGBA(155, 155, 155, 1)",
              "position": "absolute",
              "bottom": "0",
              "padding": "15px"
            },
            "txtContent": "='Uploaded on ' + toLocaleDateString([$Modified])"
          }
        ]
      }
    ]
  }
}

Note: Make sure columns you are using in JSON (like Name, Modified, etc.) are included/shown in list view. This is required for JSON formatting in SharePoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.