There is this little green !NEW icon next to new items. But what if you want the item to show as new for longer than the default 2 days?
It can be changed to as many days as you would want.
It’s a Virtual Server property and in SharePoint that relates to a Web Application, so this value will be used for all lists in the webapplication.
Change it via stsadm:
stsadm -o setproperty -pn days-to-show-new-icon -pv 7 -url [Url to your web application]
Pn stands for parameter name, and pv for parameter value.
This will change it so items are listed as new for a full week. If you set it to 0 then it will not appear at all.
It’s also a property to an SPWebApplication object, so you can change it through code too, but stsadm is by far faster.
To change it via a little console program try this:
01 using System;02 using Microsoft.SharePoint;03 using Microsoft.SharePoint.Administration;04 05 namespace CodeJourney.ChangeListItemNewPeriod06 {07 class Program08 {09 static void Main(string[] args)10 {11 //Change to point to your rootsite.12 using (SPSite site = new SPSite("http://tsd-mosstest/"))13 {14 using (SPWeb web = site.OpenWeb())15 {16 SPWebApplication WebApp = SPWebApplication.Lookup(new Uri(site.RootWeb.Url));17 int DaysToDisplayAsNew = 718 WebApp.DaysToShowNewIndicator = DaysToDisplayAsNew;19 Console.WriteLine("Press any button");20 Console.Read();21 }22 }23 }24 }25 }26
The property is from the Microsoft.SharePoint.Administration namespace.
Remember to add a reference to the Microsoft.SharePoint.dll
To just see how many days it’s set to right now:
01 using System;02 using Microsoft.SharePoint;03 using Microsoft.SharePoint.Administration;04 05 namespace CodeJourney.ChangeListItemNewPeriod06 {07 class Program08 {09 static void Main(string[] args)10 {11 //Change to point to your rootsite.12 using (SPSite site = new SPSite("http://tsd-mosstest/"))13 {14 using (SPWeb web = site.OpenWeb())15 {16 SPWebApplication WebApp = SPWebApplication.Lookup(new Uri(site.RootWeb.Url));17 Console.WriteLine("DaysToShowNewIndicator:"+WebApp.DaysToShowNewIndicator.ToString());18 Console.WriteLine("Press any button");19 Console.Read();20 }21 }22 }23 }24 }25
Related posts:
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.