Skip to main content

Create a Hyperlink column in SharePoint Online Custom List

“We would accomplish many more things if we did not think of them as impossible.”

It is possible to create a hyperlink column in SharePoint list but is it possible to create a hyperlink column as a calculated column?

The Answer is "Yesssssssssssssssssss".

Following are the steps to accomplish the same.

1. Create a Calculated Column say URL with the formula to link the list column id to a page. 

For example: ="http://sharepoint.com/sites/Test/Page.aspx?ID="&ItemID.

2.Create another calculated column say Info and refer the previously created calculated column here in anchor tag.

For example:  =IF(ISBLANK(URL),"No URL",("<a href="&URL&" target='_blank'></a>")) 

Make sure the data type returned in both the calculated columns are Numbers.

Now its time to render the Calculated column as a HTML markup in SPO.

1. Ensure that the list is in the modern experience.
2. Click on the URL column-> Column settings->Format this column.
3. A dialog would open. Please click on Advanced and paste the JSON code in the textbox.


{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Info",
  "attributes": {
    "target": "_blank",
    "href": "='@currentWeb' + '/Page.aspx?ID=' + [$ItemID]"
  }
}

Click Save and close the dialog.

Now the hyperlink column works like a charm! :)


Happy SharePointing!!! 

 

Comments

Popular posts from this blog

"An unexpected error has occurred. Changes to your data cannot be saved" excel SharePoint

“If you’re not making some notable mistakes along the way, you’re certainly not taking enough  business and career chances .” After creating a custom "Export to Excel" button on the SharePoint page as in my previous post:   https://nethrasb.blogspot.com/2020/05/export-to-spreadsheet-option-in.html we encountered an issue, where one of the user received "An unexpected error has occurred. Changes to your data cannot be saved" in the excel sheet to which the data has been exported. But I was able to export the data using "System Account" without any issue!  The user has full control over the site and there should not be any permissions related issues.  What could be the issue then?  It might seem silly but this is what happened. Humans make mistakes :) My fellow team mate who had been asked to create the view, created a "Personal" view instead of creating a "Public" view !  "Personal" view is i...

This site has exceeded its maximum storage limit.Error while uploading file to document library - SharePoint

Issue:  Unable to upload files to SharePoint document library irrespective of the document size. Solution: When you delete items from a SharePoint site, they're sent to the site Recycle Bin. When you delete items from a site Recycle Bin, they're sent to the site collection Recycle Bin.  A SharePoint site collection administrator can view and restore deleted items from the site collection Recycle Bin to their original locations. If an item is deleted from the site collection Recycle Bin, or it exceeds the retention time, it is permanently deleted. 1. Click the gear icon and go to the "Site Settings" page. 2. Under the Site Collection Administration, click on "Recycle bin". 3. Delete the unwanted files.

Unable to create a list from the custom template uploaded to the list gallery in SharePoint online

SharePoint lists can be reused on multiple sites just with a list template without having to create a custom list from the scratch.  This can be accomplished by saving the list as a template (.stp) file from the "List Settings" page. Once the template has been created, it can be uploaded to any number of sites in their "List template Gallery" at the site collection level. From here, the list can be created on any of the subsites under that site collection. The approach is same for SharePoint online as well.  But, in SharePoint online, the list could not be found under the "Add an App" section even after uploading the list template to the gallery. So how to create a list from the template in SPO when it is not listed in the Apps? 1.  Create a Custom List from the site contents and save it as a list template.  2. Click on "Add an App" and choose the OOTB list template. In the pop up where the list name to be mentioned, click on "Advanced optio...