Tuesday, August 7, 2018

Discussion List Reply Link in SharePoint 2013 and Online

Initially it was possible to achieve this using calculated column and concatenate anchor tag and generate a link. However after latest CU release, this is not possible anymore.
Following steps will help you to create a hyperlink column for discussion reply link in SharePoint 2013 or Online. Also it will help you to create a normal calculated hyperlink column in SharePoint 2013 and Online.


1. Below snap in about Discussion list default view and you are targeting to create highlighted link.

2. Create new Single link text Calculated column and add it in Discussion content type.
PN: Select Do not add it in All Content Types while creating a column.


3. Create a simple list view and make sure it consists your new calculated column.


4. Now on the list view page, add new Script Editor or Content Editor webpart.


5. Insert following script to the webpart.


<script>
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  Templates: {
        Fields: {

          //Replace "ReplyLink" with Calculated column name
           'ReplyLink': {'View':function(ctx) {
                  var url = String.format('{0}/Flat.aspx?RootFolder={1}/{2}', ctx.listUrlDir, ctx.listUrlDir,ctx.CurrentItem.Title);
                  return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, "Bid for the Job");
           }}
       }
  }
});
</script>




6. Save the page and you can access the link in Calculated column.


PN: Whenever you want such functionality, you need to add new webpart on list view page and insert the same script.