locked
How to get the description of Hyperlink column of Custom List using JSLink RRS feed

  • Question

  • Hi,

    I have done some formatting for hyperlink column of SharePoint list  using JSLink, i can get the url but i want to get description also

    below is the code for JSLink

    (function() {
        var overrideCtx = {};
        overrideCtx.Templates = {};
        overrideCtx.Templates.Fields = {
            
    		"Link": {"View": formatlink}
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
    })();
    
    function formatlink(ctx)
    {
    	
    	var appendlnk = "<a href="+ctx.CurrentItem.Link+" target='_blank'>"+ctx.CurrentItem.Link+"</a>";	
    	return appendlnk;
    
    }


    sal

    Tuesday, June 26, 2018 8:15 AM

Answers

  • Hi,

    Thanks for sharing, i have already applied below is the updated script

    function formatlink(ctx)
    {
    	var urllink = ctx.CurrentItem.Link;
    	var urldesc = ctx.CurrentItem['Link.desc'];
    	var appendlnk = "<a href="+ctx.CurrentItem.Link+" target='_blank'>"+urldesc+"</a>";	
    	return appendlnk;
    
    }


    sal

    • Marked as answer by SB Ali Tuesday, June 26, 2018 9:07 AM
    Tuesday, June 26, 2018 9:05 AM

All replies

  • Hi

    You can get the same using something like below

    ctx.CurrentItem.Link.desc

    Please mark it as an answer if it helps.

    Regards,

    • Edited by Jaydeep Mungalpara Tuesday, June 26, 2018 8:46 AM
    • Marked as answer by SB Ali Tuesday, June 26, 2018 9:07 AM
    • Unmarked as answer by SB Ali Tuesday, June 26, 2018 9:07 AM
    • Proposed as answer by SP OCEAN Tuesday, June 26, 2018 9:24 AM
    Tuesday, June 26, 2018 8:45 AM
  • Hi,

    Thanks for sharing, i have already applied below is the updated script

    function formatlink(ctx)
    {
    	var urllink = ctx.CurrentItem.Link;
    	var urldesc = ctx.CurrentItem['Link.desc'];
    	var appendlnk = "<a href="+ctx.CurrentItem.Link+" target='_blank'>"+urldesc+"</a>";	
    	return appendlnk;
    
    }


    sal

    • Marked as answer by SB Ali Tuesday, June 26, 2018 9:07 AM
    Tuesday, June 26, 2018 9:05 AM
  • Hi Ali,

    Thanks for sharing the code with us and it could help others who stuck with the same issue in the forum.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, June 27, 2018 9:28 AM