Forum Discussion
RogueWolf1985
Jul 23, 2020Copper Contributor
How do I format a SharePoint list column input to complete a URL?
Hello I am relatively new to SharePoint and JSON code. I am trying to design a list column so that when a user types in the entry the entry is then automatically converted into a URL. For example, ...
- Jul 24, 2020
RogueWolf1985 Yes, this is possible. You can use below JSON code on your ProjectName column:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "@currentField", "attributes": { "target": "_blank", "href": "='https://company.sharepoint.com/sites/ParentSite/' + @currentField" } }
Also, if "https://company.sharepoint.com/sites/ParentSite" is the same site where you are adding this JSON code then you can also use "@currentWeb" instead of hard coding the site URL in JSON like below:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"target": "_blank",
"href": "=@currentWeb + '/' + @currentField"
}
}Use column formatting to customize SharePoint
Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.
jab365cloud
Jul 23, 2020Steel Contributor
Yes it is possible. Check the github columns formatting samples here https://github.com/pnp/sp-dev-list-formatting/tree/master/column-samples/generic-hyperlink-values
- RogueWolf1985Jul 24, 2020Copper ContributorThank you for the reference! This will be helpful in the future.