Change “Create New Item” message in list web parts

Posted: March 9, 2010 in Content editor web part, javascript

Normally when we create a SharePoint List before adding any new item you will find a default text stating no item is there. For example in announcements list you may find


There are no items to show in this view of the “Announcements” list. To create a new item, click “New” above.

That’s great. But what if the user is not having permission to create a new item or if you have removed the toolbar of the web part. Or think you have displayed an Announcement web part in your home page, asking the visitor to create a new announcement.

To change this default text displayed use the script below

<script>
function ChangeNewMessage()
{

var a = document.getElementsByTagName(“TD”)
for (var i=0;i<a.length;i++)
{
if (a[i].className==”ms-vb”)
{
if (a[i].innerText.indexOf(“
There are no items to show in this view of the “Announcements” list. “)>-1)
{
a[i].innerHTML = “Coming Soon..”;
}
}
}
}

_spBodyOnLoadFunctionNames.push(“ChangeNewMessage”)
</script>


You just want to change the “There are no items to show in this view of ” text for different lists.


Advertisements
Comments
  1. Assefa says:

    Nice Tip! One thing; you need to break once you find the required TD and set the innerHTML.

    a[i].innerHTML = “Coming Soon..”;
    break;

    Thanks,

  2. Pawel Czarnota says:

    Where on the page do I place this script? I tried adding it to the page using SharePoint designer right after the Web Part zone ends, but the script never loads and doesn’t even appear in View Source of the page. Thanks

  3. Fi says:

    Thanks for the scripts! But unfortunately it didn’t work on my sharepoint site. So what I did was open the site with Sharepoint Designer. In the Default.apsx page I searched for “There are no items to show in this view of” text in the code and replaced the text with the message I want to display e.g. “No new messages.” Works for all lists and calendar events.

    • chanakya01 says:

      This script will be for that particular page where you have placed it.
      But changing default.aspx will affect all the lists in your site. But it works 🙂

      Thanks

  4. Jonathan says:

    Hi !
    It works perfectly for me but I had to modify ” to ‘ .
    I’ve got a question : it works on Internet explorer but not on Firefox…Do you know if there is something to do ?

  5. MauroWagner says:

    Hello!
    I put this script into a Content Editor Web part, but it works only for the first List Web Part into the page. I have several List web parts into a page and I want to replace the text for everyone.
    What should I change in that script?
    Thanks!

  6. Ali says:

    You cannot just copy & paste the code from this site to your Sharepoint Content Editor Web Part. You have to replace all quotation masks, then it will work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s