Jul 23 2020 07:25 AM
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, the input is ProjectName and the final column output is https://company.sharepoint.com/sites/ParentSite/ProjectName.
Is this:
a) possible?
b) if possible how would I go about being able to do this?
c) can I further format the output to show just the ProjectName but formatted as a hyperlink?
Thank you in advance!
Jul 23 2020 04:43 PM
Jul 23 2020 09:16 PM - edited Jul 23 2020 09:26 PM
Solution@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.
Jul 24 2020 05:49 AM
Jul 24 2020 05:50 AM
Jul 24 2020 05:55 AM
Jul 23 2020 09:16 PM - edited Jul 23 2020 09:26 PM
Solution@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.