1

I'm pretty much new to JSON. I am formatting a SP form footer to show an Image (saved in SP folder) that will automatically update based on selected data from the Choice column

below code is working with only 1 condition:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "img",
    "attributes": {
        "src": "=if([$Criterias] =='Skills' && [$Awards] =='Personal' , 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Presentation.png?csf=1&web=1&e=TOjVGh', 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Blank%20Footer.png?csf=1&web=1&e=gdAknf')"
    },
    "style": {
        "position": "relative",
        "top": "100%",
        "left": "100%",
        "width": "100%",
        "max-width": "100%",
        "height": "100%",
        "margin-left": "-100%",
        "margin-top": "0%"
    }
}

But if I add a condition. it's not working anymore. please see below code. thank you so much in advance.

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "img",
    "attributes": {
        "src": "=if([$Criterias] =='Skills' && [$Awards] =='Personal' , 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Presentation.png?csf=1&web=1&e=TOjVGh', =if([$Criterias] =='Skills2' && [$Awards] =='Personal2' , 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Presentation222.png?csf=1&web=1&e=TOjVGh','https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Blank%20Footer.png?csf=1&web=1&e=gdAknf'))"
    },
    "style": {
        "position": "relative",
        "top": "100%",
        "left": "100%",
        "width": "100%",
        "max-width": "100%",
        "height": "100%",
        "margin-left": "-100%",
        "margin-top": "0%"
    }
}

1 Answer 1

0

You have a extra "equal to (=)" operator in the expression added for src attribute.

Try removing and using JSON in this format:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "img",
  "attributes": {
    "src": "=if([$Criterias] == 'Skills' && [$Awards] == 'Personal', 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Presentation.png?csf=1&web=1&e=TOjVGh', if([$Criterias] == 'Skills2' && [$Awards] == 'Personal2', 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Presentation222.png?csf=1&web=1&e=TOjVGh', 'https://xxxx.sharepoint.com/:i:/r/teams/IIICCCC/Shared%20Documents/IC%20ADHOC%202025/Rewards%20%26%20Recognition/Personal%20Development%20Criteria%20(Images)/Blank%20Footer.png?csf=1&web=1&e=gdAknf'))"
  },
  "style": {
    "position": "relative",
    "top": "100%",
    "left": "100%",
    "width": "100%",
    "max-width": "100%",
    "height": "100%",
    "margin-left": "-100%",
    "margin-top": "0%"
  }
}

Where [$Criterias] and [$Awards] are an internal name of your columns in SharePoint list in this format: [$InternalNameOfColumn].

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?

2
  • 1
    wow thank you so much for this. it works perfect now. Again, thank you so much :) Commented Jun 17 at 4:34
  • You are welcome! Glad it worked for you. Commented Jun 17 at 5:28

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.