Feeds:
Posts
Comments

Archive for February, 2013

As promised, here is the follow-up post from Mysteries of the “New” icon

Notice in this screen shot that we have two identical items:

Announcements list with two seemingly identical items. Only, one of the items has the "New!" icon.

Announcements list with two seemingly identical items. Only, one of the items has the “New” icon.

Whoa! How did this happen?

In the process of migrating a site from one web template to another (yes, another post to come, but this one may take a while since it’s pretty in-depth), I had created an export of a site and imported it using Import-SPWeb as such:

PS C:> Export-SPWeb http://sppaule/sites/test/oldSite -path 
   D:\Exports\old_Site -IncludeVersions 4 -NoFileCompression 
   -IncludeUserSecurity
PS C:> New-SPWeb http://sppaule/sites/test/newSite -Template "STS#1"
PS C:> Import-SPWeb http://sppaule/sites/test/newSite -Path 
   D:\Exports\old_site -NoFileCompression -IncludeUserSecurity

Now, the first time I did the import, there was no problem. Everything looked good. However, I didn’t stop there. I made a few tweaks to the export and re-issued the import command without first deleting the previous import. Instead of completely overwriting the previous import, a merge of the first import was done with the second import. Document libraries handle this without too much hassle, but the Ann0uncements list did not. The first item shown in the screen shot above was from the first import, and the second item was from the second import.

During the import process, SharePoint puts in the Created and Modified dates from the export data (i.e. the original dates). However, on import, the current date is put in for the fields with InternalName of Created_x0020_Date and Last_x0020_Modified. Since the two imports were done roughly a day apart, I ended up with a Created_x0020_Date field value for the two items that was also roughly a day apart and the New icon showed for only the more recent item.

I wouldn’t be surprised if the import merge was a result of the specific way I exported and imported or even may have had something to do with the small tweaks made to the export before re-import. Either way, I have learned a lesson: Always best to start with a clean slate when importing. As such, I should have done the following:

PS C:> Export-SPWeb http://sppaule/sites/test/oldSite -path 
   D:\Exports\old_Site -IncludeVersions 4 -NoFileCompression 
   -IncludeUserSecurity
PS C:> New-SPWeb http://sppaule/sites/test/newSite -Template "STS#1"
PS C:> Import-SPWeb http://sppaule/sites/test/newSite -Path 
   D:\Exports\old_site -NoFileCompression -IncludeUserSecurity
PS C:> Remove-SPWeb http://sppaule/sites/test/newSite
PS C:> New-SPWeb http://sppaule/sites/test/newSite -Template "STS#1"
PS C:> Import-SPWeb http://sppaule/sites/test/newSite -Path 
   D:\Exports\old_site -NoFileCompression -IncludeUserSecurity

Happy learning day!

Read Full Post »

It’s been far too long since I last blogged. To my followers: my apologies. There have been some great discoveries (particularly in the last few months), but none I have had time to write about, yet. Today, I ran into an intriguing situation that I felt needed to be shared that wouldn’t take long.

Take a look at this screen shot:

Announcements list with two seemingly identical items. Only, one of the items has the "New!" icon.

Announcements list with two seemingly identical items. Only, one of the items has the “New” icon.

Notice anything funny? (Okay, so I gave it away if you looked at the caption.) We’ve got two seemingly identical announcements in this list: both have the same title, creation date, and modification date. Only, one of them is showing the New icon and the other isn’t. I had to take a hard look at this!

Let’s disregard how I got to this for now and focus on the question at hand: Why would one item show the New icon and the other item not? They both show the same Created date and that is clearly not anywhere close the the timeframe for a new item (nearly a whole year earlier). Diving under the hood with PowerShell brought about the answer.

Let’s say $i1 and $i2 are, respectively, the SPListItem objects in PowerShell from the list shown above. My first clue came from inspecting the XML of $i2. There were clearly two dates given for the creation date, as such:

ows_Created='2012-02-29 15:17:19'
ows_Created_x0020_Date='1;#2013-02-20 17:46:57'

Again, let’s disregard how I came about with two different Created dates. It becomes clear that the New icon is going off the Created_x0020_Date field data. Furthering the inspection in PowerShell, we see the following:

PS C:> $f = $i1.Fields.GetFieldByInternalName("Created_x0020_Date")
PS C:> $i1[$f.id]
2013-02-19 16:44:52
PS C:> $i1["Created"]
Wednesday, February 29, 2012 3:17:19 PM

PS C:> $f = $i2.Fields.GetFieldByInternalName("Created_x0020_Date")
PS C:> $i2[$f.id]
2013-02-20 17:46:57
PS C:> $i2["Created"]

Wednesday, February 29, 2012 3:17:19 PM

Viola! Item 1 has a Created_x0020_Date that is outside of the range for a New icon, but Item 2 has a date within the range and thus shows the New icon.

The creation date shown in list views is the Created field where Title = "Created" and InternalName = "Created". While also having Title = "Created", the field used by the New icon is the one with InternalName = "Created_x0020_Date". You never see this later field (Created_x0020_Date) in the UI because it is hidden and readonly.

I’ll discuss how I came about this duplication in my next post, Duplicated list items.

P.S.–
If you need to see or change the duration your web application is set to for the New icon (i.e. how long the New icon will show), use the following PowerShell (copied from Deliveron Blog):

Get The Current Duration To Display The “New” Icon
$webApp = Get-SPWebApplication "http://webAppURL/"
$webApp.DaysToShowNewIndicator

Change The Duration To Display The “New” Icon
# Set to 1 Day
$webApp = Get-SPWebApplication "http://webAppURL/"
$webApp.DaysToShowNewIndicator = 1
$webApp.Update()

Prevent The “New” Icon From Displaying
# Essentially, just set the display duration to 0 days.
$webApp = Get-SPWebApplication "http://webAppURL/"
$webApp.DaysToShowNewIndicator = 0
$webApp.Update()

Read Full Post »