1

Wondering if someone could take a look at my JSON coding on my SharePoint list to see why it isn't linking up the User's Delve account profile picture?

enter image description here

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "min-height": "1.5em",
    "flex-direction": "column",
    "align-items": "flex-start"
  },
  "children": [
    {
      "elmType": "div",
      "forEach": "person in @currentField",
      "style": {
        "margin-top": "=if(loopIndex('person') == 0, '0', '1em')"
      },
      "children": [
        {
          "elmType": "div",
          "style": {
            "display": "flex",
            "flex-direction": "row"
          },
          "children": [
            {
              "elmType": "img",
              "attributes": {
                "src": "='/_layouts/15/userphoto.aspx?size=S&accountname='+ [$person.email]"
              },
              "style": {
                "width": "1.5em",
                "height": "1.5em",
                "border-radius": "3em"
              }
            },
            {
              "elmType": "a",
              "attributes": {
                "href": "='https://shermanmanagement-my.sharepoint.com/PersonImmersive.aspx?accountname=i:0%23.f|membership|'+ [$person.email]",
                "target": "_blank"
              },
              "style": {
                "margin-left": "0.5em"
              },
              "children": [
                {
                  "elmType": "div",
                  "txtContent": "[$person.title]",
                  "style": {
                    "font-size": "1.2em"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
3
  • Are you getting any error in developer console? Also, are you able to redirect to the delve profile using URL attached to user name? Do you have any person or group type column with internal name person in your list? Commented Mar 3, 2020 at 16:22
  • @GaneshSanap I don't believe I am getting an error in developer console.. What do you mean by redirecting the delve profile using a URL? I do not have a column with the internal name person on my list.
    – Francis
    Commented Mar 3, 2020 at 16:45
  • You are using [$person.email] in your JSON. In order to use this, you should have a column with person as a internal name and "Person or Group" as a data type in your list. Commented Mar 4, 2020 at 2:16

1 Answer 1

0

If you want to show the user's Delve account profile picture, we can use Delve api to achieve it.

/_vti_bin/DelveApi.ashx/people/profileimage?size=L&[email protected]

Modify the JSON code as follows.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "min-height": "1.5em",
    "flex-direction": "column",
    "align-items": "flex-start"
  },
  "children": [
    {
      "elmType": "div",
      "forEach": "person in @currentField",
      "style": {
        "margin-top": "=if(loopIndex('person') == 0, '0', '1em')"
      },
      "children": [
        {
          "elmType": "div",
          "style": {
            "display": "flex",
            "flex-direction": "row"
          },
          "children": [
            {
              "elmType": "img",
              "attributes": {
                "src": "='/_vti_bin/DelveApi.ashx/people/profileimage?size=S&userId='+ [$person.email]"
              },
              "style": {
                "width": "1.5em",
                "height": "1.5em",
                "border-radius": "3em"
              }
            },
            {
              "elmType": "a",
              "attributes": {
                "href": "='https://shermanmanagement-my.sharepoint.com/PersonImmersive.aspx?accountname=i:0%23.f|membership|'+ [$person.email]",
                "target": "_blank"
              },
              "style": {
                "margin-left": "0.5em"
              },
              "children": [
                {
                  "elmType": "div",
                  "txtContent": "[$person.title]",
                  "style": {
                    "font-size": "1.2em"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
1
  • I copied your code in my list and it is still showing up as the gray head outlines. Was there something I still needed to adjust within your coding?
    – Francis
    Commented Mar 6, 2020 at 17:28

Your Answer

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

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