SOLVED

How do I format a SharePoint list column input to complete a URL?

%3CLINGO-SUB%20id%3D%22lingo-sub-1541150%22%20slang%3D%22en-US%22%3EHow%20do%20I%20format%20a%20SharePoint%20list%20column%20input%20to%20complete%20a%20URL%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1541150%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20I%20am%20relatively%20new%20to%20SharePoint%20and%20JSON%20code.%26nbsp%3B%20I%20am%20trying%20to%20design%20a%20list%20column%20so%20that%20when%20a%20user%20types%20in%20the%20entry%20the%20entry%20is%20then%20automatically%20converted%20into%20a%20URL.%26nbsp%3B%20For%20example%2C%20the%20input%20is%20%3CSTRONG%3EProjectName%3C%2FSTRONG%3E%20and%20the%20final%20column%20output%20is%20%3CA%20href%3D%22https%3A%2F%2Fcompany.sharepoint.com%2Fsites%2FParentSite%2FProjectName.%26nbsp%3B%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcompany.sharepoint.com%2Fsites%2FParentSite%2FProjectName.%26nbsp%3B%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%3A%3C%2FP%3E%3CP%3Ea)%20possible%3F%3C%2FP%3E%3CP%3Eb)%20if%20possible%20how%20would%20I%20go%20about%20being%20able%20to%20do%20this%3F%3C%2FP%3E%3CP%3Ec)%20can%20I%20further%20format%20the%20output%20to%20show%20just%20the%20ProjectName%20but%20formatted%20as%20a%20hyperlink%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1541150%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1542999%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20format%20a%20SharePoint%20list%20column%20input%20to%20complete%20a%20URL%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1542999%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F737810%22%20target%3D%22_blank%22%3E%40RogueWolf1985%3C%2FA%3E%26nbsp%3BYes%2C%20this%20is%20possible.%20You%20can%20use%20below%20JSON%20code%20on%20your%20%3CSTRONG%3EProjectName%3C%2FSTRONG%3E%20column%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%20%20%22elmType%22%3A%20%22a%22%2C%0A%20%20%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%0A%20%20%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22target%22%3A%20%22_blank%22%2C%0A%20%20%20%20%20%20%20%20%22href%22%3A%20%22%3D'https%3A%2F%2Fcompany.sharepoint.com%2Fsites%2FParentSite%2F'%20%2B%20%40currentField%22%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20if%20%22%3CA%20href%3D%22https%3A%2F%2Fcompany.sharepoint.com%2Fsites%2FParentSite%2FProjectName.%25C2%25A0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcompany.sharepoint.com%2Fsites%2FParentSite%3C%2FA%3E%22%20is%20the%20same%20site%20where%20you%20are%20adding%20this%20JSON%20code%20then%20you%20can%20also%20use%20%22%3CSTRONG%3E%40currentWeb%22%26nbsp%3B%3C%2FSTRONG%3Einstead%20of%20hard%20coding%20the%20site%20URL%20in%20JSON%20like%20below%3A%3C%2FP%3E%3CPRE%3E%7B%3CBR%20%2F%3E%20%20%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%3CBR%20%2F%3E%20%20%20%20%22elmType%22%3A%20%22a%22%2C%3CBR%20%2F%3E%20%20%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%3CBR%20%2F%3E%20%20%20%20%22attributes%22%3A%20%7B%3CBR%20%2F%3E%20%20%20%20%20%20%20%20%20%22target%22%3A%20%22_blank%22%2C%3CBR%20%2F%3E%20%20%20%20%20%20%20%20%20%22href%22%3A%20%22%3D%40currentWeb%20%2B%20'%2F'%20%2B%20%40currentField%22%3CBR%20%2F%3E%20%20%20%20%20%7D%3CBR%20%2F%3E%7D%3C%2FPRE%3E%3CP%3E%3CA%20title%3D%22Use%20column%20formatting%20to%20customize%20SharePoint%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fcolumn-formatting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUse%20column%20formatting%20to%20customize%20SharePoint%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20solve%20your%20issue.%20This%20will%20help%20others%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20content%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3E%3CSTRONG%3ELike%3C%2FSTRONG%3E%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1542773%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20format%20a%20SharePoint%20list%20column%20input%20to%20complete%20a%20URL%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1542773%22%20slang%3D%22en-US%22%3EYes%20it%20is%20possible.%20Check%20the%20github%20columns%20formatting%20samples%20here%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2Fsp-dev-list-formatting%2Ftree%2Fmaster%2Fcolumn-samples%2Fgeneric-hyperlink-values%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fpnp%2Fsp-dev-list-formatting%2Ftree%2Fmaster%2Fcolumn-samples%2Fgeneric-hyperlink-values%3C%2FA%3E%3C%2FLINGO-BODY%3E
New Contributor

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!

5 Replies
best response confirmed by RogueWolf1985 (New Contributor)
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.

Perfect! Thank you so much!
Thank you for the reference! This will be helpful in the future.
Great, glad it worked for you.