How can I change the text colour of a SharePoint lookup column without losing hyperlink functionality?

Jordan Daley 20 Reputation points
2024-06-14T18:07:43.25+00:00

I'm having trouble maintaining the hyperlink functionality of my SharePoint lookup column after changing its text colour. I need to change the colour of this field, but it should still open a new tab when clicked, and when clicked while in detailed view, a mini dialogue list should appear. I have the JSON code that I'm currently using, and I'm looking for a solution that will help me achieve both goals.

Microsoft 365 and Office | SharePoint | Development
{count} votes

Accepted answer
  1. Yanli Jiang - MSFT 31,601 Reputation points Microsoft External Staff
    2024-06-17T06:57:15.6333333+00:00

    Hi @Jordan Daley ,

    Welcome to Q&A forum!

    To change the text color of a SharePoint lookup column without losing the hyperlink functionality, you can use the following JSON code:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "a",
      "attributes": {
        "href": {
          "operator": "+",
          "operands": [
            "/sites/FieldOperations/Lists/Building%20List/DispForm.aspx?ID=",
            "@currentField.lookupId",
            "&IsDlg=1"
          ]
        },
        "style": {
          "text-decoration": "underline",
          "color": "#89cff0"
        },
        "target": "_blank",
      },
      "txtContent": "@currentField.lookupValue"
    }
    

    Note that the "target": "_blank" attribute opens the hyperlink in a new tab.

    But unfortunately, the mini dialogue list behavior isn’t directly achievable using column formatting.


    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 additional answers

Sort by: Most helpful

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.