Sorry for the late response. I had off work due to illness.
Please check the following:
(1) The column is of type Multiple lines of text, and the type of text is set as Plain Text
(2) Here, I'm viewing/editing the url2 column.
(3) JSON column formatting code. Delete the existing code, and then copy-and-paste the following:
If url2 column contains html tags such as <p> or <br> etc, the JSON code below won't work.
<p>https://en.wikipedia.org/wiki/Main_Page?test_parameter_to_ensure_that_the_length_of_this_url_is_well_over_three_hundred_characters_so_it_can_be_used_to_test_email_systems_or_other_software_that_might_have_limits_on_hyperlink_lengths_while_still_remaining_a_perfectly_valid_link_that_will_load_the_wikipedia_home_page_without_issue</p>
This url text should work:
https://en.wikipedia.org/wiki/Main_Page?test_parameter_to_ensure_that_the_length_of_this_url_is_well_over_three_hundred_characters_so_it_can_be_used_to_test_email_systems_or_other_software_that_might_have_limits_on_hyperlink_lengths_while_still_remaining_a_perfectly_valid_link_that_will_load_the_wikipedia_home_page_without_issue
Here is the JSON code again:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"attributes": {
"href": "@currentField",
"target": "_blank"
},
"txtContent": "Open link",
"style": {
"display": "=if(@currentField == '', 'none', '')"
}
}
Here is a modified JSON code (version 2) for you to try. Both versions work on my test environment. Delete the existing code, and then copy-and-paste the following:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"attributes": {
"href": "@currentField",
"target": "_blank"
},
"txtContent": "Open link",
"style": {
"display": "=if(length(@currentField) > 0, 'inline', 'none')"
}
}
In this version, if there are more than 0 characters typed into the url2 box, show the "Open link" hyperlink. If there are 0 characters (the box is completely blank), hide "Open link" hyperlink so we don't get a broken link.
Ellis Karim
elliskarim.com | LinkedIn | Bluesky
If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!