I'm writing an IF statement in JSON formatting to get a particular image for a card view.

Basically, if the SharePoint field 'IndOrTeam' equals 'Team', then a group image stored in Site Assets is shown. This is working fine, however if 'IndOrTeam' does NOT equal 'Team' I want to show the user's profile picture, who is set in the 'AssignedTo' field. I know this can be accessed by the operator '=getUserImage([$AssignedTo], 'L')' but I can't get it to work in the IF statement.

If I remove the IF statement altogether, the user profile pic is shown as expected. The code is below. Does anyone know why it isn't showing the user profile image:

elmType": "img",
          "style": {
            "width": "150px",
            "height": "150px",
            "border-radius": "50%",
            "border": "1px solid"
          "attributes": {
            "src": "=if([$IndOrTeam] == 'Team','https://xxxxx.sharepoint.com/sites/Intranet/SiteAssets/groupusers.png','=getUserImage([$AssignedTo.email], 'L')'",
            "class": "ms-fontColor-neutralTertiaryAlt"
          "defaultHoverField": "[$AssignedTo]"

Thanks in advance.

1 Answer 1


Try using SharePoint JSON formatting expression like this:

"src": "=if([$IndOrTeam] == 'Team', 'https://xxxxx.sharepoint.com/sites/Intranet/SiteAssets/groupusers.png', getUserImage([$AssignedTo.email], 'l'))",

Where IndOrTeam and AssignedTo are internal name of your SharePoint list columns. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

  • 1
    Thanks. Updated the code. I'm sure I'd tried to re-write like that previously, but must have missed something or made a mistake. Now it works as expected! :) Commented Oct 4, 2023 at 14:07
  • You're welcome, glad it worked for you! Commented Oct 4, 2023 at 14:12

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.