Problem on JSON formating with lookup Column coming from another list

Patgat 0 Reputation points
2024-01-04T16:09:15.0733333+00:00

Hi,

In my List B, I have a lookup column "LookUp Column" coming from an other SharePoint list A in date format.

On a field of the B List I try to do a JSON column formating with a test on "LookUp Column" coming from A List.

Is it possible?

I tried different solutions which did not worked (though i got no error on debug mode)=>

[$LookUp Column.lookupValue] [$LookUp_x0020_Column.lookupValue] @currentField.LookUp Column.lookupValue @currentField.LookUp_x0020_Column.lookupValue

I never get nothing as result.

Please can somebody help me?

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
    2024-01-05T03:03:22.2566667+00:00

    Here is an example for you:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "debugMode": true,
      "txtContent": "@LookUpColumn.lookupValue",
      "style": {
        "color": "=if([$LookUpColumn.lookupValue] == 'testA', '#ff0000', '')"
      }
    }
    

    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.

    0 comments No comments

  2. Patgat 0 Reputation points
    2024-01-06T08:12:03.6466667+00:00

    I'm sorry but i did not give all precisions. I give correction underneath.

    In my List A I have a lookup column "CODE PROJET" and one connected lookup column "FIN RECONDCT" both coming from an other SharePoint list B.

    Screen1

    On a field of the A List I try to do a JSON column formating with a test on "FIN RECONDCT" coming from B.

    I get fine the value of "CODE PROJET" doing [$CODE_x0020_PROJET.lookupValue] but I never get the value of the connected field "FIN RECONDCT"

    I tried different solutions. But whatever name I use to get the value, I get no error (in debug mode) and no value. I tried all these =>

    [$FIN_x0020_RECONDCT.lookupValue] [$CODE_x0020_PROJET:FIN_x0020_RECONDCT.lookupValue] [$CODE_x0020_PROJET.FIN_x0020_RECONDCT.lookupValue] [$CODE_x0020_PROJET:$FIN_x0020_RECONDCT.lookupValue] [$CODE_x0020_PROJET.$FIN_x0020_RECONDCT.lookupValue]

    Please can somebody help me?

    0 comments No comments

  3. Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
    2024-01-08T03:23:24.41+00:00

    Here is an example for you:

    1.In the SharePoint list A, there are two columns CODE PROJET and FIN RECONDCT.

    User's image

    2.In the SharePoint list B, there is a lookup column,

    User's image

    3.Go to the List settings -> Click CODE PROJET: FIN RECONDCT in the Columns section -> Copy the internal name of the column.

    1

    4.To get values of additional lookup column, use [$CODE_x0020_PROJET_x003a__x0020_F] in the JSON formatting codes.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "debugMode": true,
      "txtContent": "[$CODE_x0020_PROJET_x003a__x0020_F]",
      "style": {
        "color": "=if([$CODE_x0020_PROJET_x003a__x0020_F] == 'A', '#ff0000', '')"
      }
    }
    

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.