how to make conditional format on data type:lookup for sharepoint list

Fahad Shaheen 20 Reputation points
2023-01-30T08:02:33.3033333+00:00

Hello,

Am using SharePoint 365 and I tried to make conditional format on 1 column (type: lookup) that reads from another list in the site called (dropdown list) , but am getting an error : [object Object] on this column

(on left side of the table is what I need , on the right side is the error am getting )

on the left side date type is (choice)

on the Right side date type is (lookup)

msedge_l2Baq9K97r

am using the code below on both column but it's only applied on one of them, anyone know why ?



{
	"elmType": "div",
	"txtContent": "@currentField",
	"style": {
		"color": "#000000",
		"padding-left": "14px",
                "font-weight": "bold",
		"background-color": {
			"operator": "?",
			"operands": [{
					"operator": "==",
					"operands": [
						"@currentField",
						"Highly Probable"
					]
				},
				"#C00000",
				{
					"operator": "?",
					"operands": [{
							"operator": "==",
							"operands": [
								"@currentField",
								"Probable"
							]
						},
						"#FF0000",
						{
							"operator": "?",
							"operands": [{
									"operator": "==",
									"operands": [
										"@currentField",
										"Possible"
									]
								},
								"#FFC000",
								{
									"operator": "?",
									"operands": [{
											"operator": "==",
											"operands": [
												"@currentField",
												"Improbable"
											]
										},
										"#D4D919",
										{
											"operator": "?",
											"operands": [{
													"operator": "==",
													"operands": [
														"@currentField",
														"Highly Improbable"
													]
												},
												"#00B050",
												""
											]
										}
									]
								}
							]
						}
					]
                }]
			}
		}}
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,881 questions
0 comments No comments
{count} votes

Accepted answer
  1. Haoyan Xue_MSFT 20,906 Reputation points Microsoft Vendor
    2023-01-30T08:44:11.3+00:00

    Hi @Fahad Shaheen ,

    Please use the following code (replace all occurrences of @currentField with @currentField.lookupValue):

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField.lookupValue",
      "style": {
        "color": "#000000",
        "padding-left": "14px",
        "font-weight": "bold",
        "background-color": {
          "operator": "?",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "@currentField.lookupValue",
                "Highly Probable"
              ]
            },
            "#C00000",
            {
              "operator": "?",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "@currentField.lookupValue",
                    "Probable"
                  ]
                },
                "#FF0000",
                {
                  "operator": "?",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "@currentField.lookupValue",
                        "Possible"
                      ]
                    },
                    "#FFC000",
                    {
                      "operator": "?",
                      "operands": [
                        {
                          "operator": "==",
                          "operands": [
                            "@currentField.lookupValue",
                            "Improbable"
                          ]
                        },
                        "#D4D919",
                        {
                          "operator": "?",
                          "operands": [
                            {
                              "operator": "==",
                              "operands": [
                                "@currentField.lookupValue",
                                "Highly Improbable"
                              ]
                            },
                            "#00B050",
                            ""
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    }
    
    

    The running result is as below:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Fahad Shaheen 20 Reputation points
    2023-01-30T11:00:38.1+00:00

    @Haoyan Xue_MSFT YES ! it's works with ZERO error

    Thanks a lot, you save my Day

    0 comments No comments