List view web parts are very useful to show the summarize information for the lists and user can easily walk through all list items in quick glance. Normally we keep columns with smaller values in list view like Title, date, status, type and priority etc. to have user friendly view of the list. But sometime we get the requirement to show lists with images or multiline text fields to get more detail on list view page instead of going to list item detail. Sometime this result in unreadable output with long vertical scroll on the page.

To minimize this effort, I am sharing a JSLink script and its integration detail to trim the multiline text field and show the text in tool tip instead on the page.

Below is a simple script which you can save in SharePoint’s siteassets or any other document library:

(function () {
    var priorityFiledContext = {};
    priorityFiledContext.Templates = {};
    priorityFiledContext.Templates.Fields = {
        "Project_x0020_Notes": {
            "View": bodyFiledTemplate

function bodyFiledTemplate(ctx) {
    var bodyValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    //This regex expression use to delete html tags from the Body field 
    var regex = /(<([^>]+)>)/ig;
    bodyValue = bodyValue.replace(regex, "");
    var newBodyValue = bodyValue;
    if (bodyValue && bodyValue.length >= 100) {
        newBodyValue = bodyValue.substring(0, 100) + " ...";
     bodyValue  = bodyValue.replace(/'/g, " ");
      return "<span title='" + bodyValue + "'>" + newBodyValue + "</span>";

Below are steps to integrate JSLink file on a list view webpart:

  1. Edit the list view page, this will show the list web part in edit able mode.
  2. Open the web part properties for list view web part.
  3. Scroll down and expand the Miscellaneous node and enter the url of JSLink file as shown in below screenshot

jslink edit web part

  1. Press Ok to save the changes, and then save changes on the page and you can see output similar to below screenshot which showing trimmed multiline text field and it’s full detail in tool tip.

JSlink tooltip

I just rich text field to show output as plan text, you can also play with the css for a better look n feel for the tooltip.

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply