Modifying a page in SharePoint 2010 breaks the XML Viewer WebPart

In SharePoint 2007 it was a known fact that when you edit a page with SharePoint designer, unexpected behavior could occur after saving it! Extra tags in your MasterPage, PageLayout and style references you don’t want..

I now have come to the conclusion that this hasn’t changed in SharePoint 2010.

Place an XML Viewer WebPart on a SharePoint 2010 page, edit the XSL for that WebPart(For instance: Display a RSS Feed)  and save the page.

When you now open that same page with SharePoint designer, do some adjustments on listviews, dataviews or change a random property on that page, save it, the XML Viewer WebPart is broken!

What happens?

After editing the page with SharePoint Designer some extra “enters”(CR) are put in the XSL of the XML Viewer WebPart and thus the WP is not displaying anything anymore…

Original:

image

After SPD:

image

Which results in a XML Viewer WebPart not displaying the requested results anymore..

image

“Solution/Workaround”:

Put your XSL Style Sheet in a separate file on the SharePoint site, and refer to that file from the XML Viewer WebPart so that SharePoint Designer cannot screw up the XSL anymore..

image

XML Viewer WebPart displaying some random RSS Feed.. (oh I don’t drink Heineken btwKnipogende emoticon)

image

The “What’s New” WebPart in a SharePoint 2010 Group Work Site

In SharePoint 2010 there is a new template called “Group Work Site”. A Group Work site is basically just a Blank Site template with some extra added WebParts that stimulate group activities such as:

  • Group Calendar (Use the Calendar list to keep informed of upcoming meetings, deadlines.)
  • Circulations (Use this list to inform team members and request confirmation stamps.)
  • Phone Call Memo (Use this list to share the incoming phone call information.)
  • Resources (Use this list to document shared assets, such as cameras and vehicles. Users can reserve and track listed resources in Group Calendar.)
  • Whereabouts (Use this list to quickly and easily track the location of individuals throughout the day.)
    image

After creating a SharePoint site based upon the “Group Work Site” template you immediately will notice the purpose of the site, if that was not already clear to you due to the obvious template title ;)… There is a BIG calendar view on the homepage!

image

The WebPart I would like to demo is the “What’s New” WebPart which allows you to have updated information always available in just one view, the homepage!image

What does it do?

It displays all items from pre-selected lists where your username occurs in a pre determined column, to make that more clear a screenshot with the WebPart settings:

As you can see you are free to add or remove a list from the “What’s New” WebPart.

Important: At the bottom of the WebPart settings there is a line:

Only lists that have indexes on [Modified] column can be added to this web part. To enable index, go to the list setting page

 

 

 

 

 

 

 

When you have created a custom list or for instance a document library, just click on “Metadata navigation settings”.In the next properties window you can configure key filters, there you need to add the “Modified” column.

image

This makes sure that you can select your custom document library in the “What’s New” WebPart so that you get to see updates from that library as well.

image

Select the column that you want the “What’s New” WebPart to filter with your username.

Off course you can think of solutions where you have added a custom column of the type “Person or Group” and filter by that column in the “What’s New” WebPart.

Result:

Pretty basic overview of items in different lists.

image

It can also show your items with a little bit more details:

image

Conclusion:

Easy to use, easy to configure query WebPart that keeps you updated on a user friendly manner.

Handy!

Hiding the “Workspace” checkbox when creating a calendar event

If you would like to use the calendar list for creating events and don’t want to give your users the option to create a “Meeting Workspace”, hide the field.

There are a lot of possibilities to hide fields from the newform.aspx and dispform.aspx pages, for instance:

    1. Powershell script to show/hide columns when a user chooses to create, edit or view an item. It does not work for system fields.
    2. Javascript to search for a field on the page that machtes a searchquery.

    Powershell
    This you can use for hiding SharePoint fields you have created. Not for SharePoint system fields….

function Hide-SPField([string]$url, [string]$List, [string]$Field) {
  [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

  $SPSite = New-Object Microsoft.SharePoint.SPSite($url)
  $OpenWeb = $SPSite.OpenWeb()

  $OpenList = $OpenWeb.Lists[$List]

  $OpenField = $OpenList.Fields[$Field]
  $OpenField.ShowInNewForm = $True
  $OpenField.ShowInEditForm = $False
  $OpenField.ShowInDisplayForm = $False
  $OpenField.Update()

  $SPSite.Dispose()
  $OpenWeb.Dispose()
}

Hide-SPField -url http://YourURL/ -List “List Name” -Field “Field name”

Javascript
This you can use to hide any field on the page you want it to. Create a “script.txt” file in the list folder with SharePoint designer and copy paste the code below.

image

Then just put a content editor WebPart on for instance the “newform.aspx” and enter the link to your script file.

image

<script type=”text/javascript”>
var theRows = document.getElementsByTagName(“TR”);
var r = 0;
var strTitle = “”;
while (r < theRows.length)
{ try
{ strTitle = theRows[r].innerText || theRows[r].textContent;
strTitle = strTitle.replace(/\n|\r|\t|\^ /g,””);
if (strTitle.search(“Workspace”) == 0)
{ theRows[r].style.display = “none”; }
}
catch(err){}
r+=1;
}
</script>

image

Display RSS feed with a XML Viewer WebPart in SharePoint Foundation

If you are working with SharePoint foundation and you would like to display an rss feed, for SharePoint Server you would choose to use the rss-viewer WebPart. In SharePoint Foundation there is no RSS-Viewer WebPart so you have to come up with an alternative.

From a customer I received the following request: They wanted newsfeeds from branch organizations all over the world combined into one rss feed and display that one on their corporate marketing portal. For the combine functionality I used “yahoo pipes”. It is an easy interface, with all options you need such as filtering, sorting etc. Once you created a pipe there is also a combined rss feed available that will show you all separate feeds into one.

To display that newly created rss feed, just put a XML-Viewer WebPart on your page in SharePoint 2010, add the url to the combined rss feed at yahoo. If you would hit enter now, the WebPart will display all properties the rss feed outputs. That is unreadable!

To make it readable you need to add some XSL formatting, for example enter the next code at your “XSL Editor”.

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:param name="TITLE"/> <xsl:template match="rss"> <div style="background:#ffffff; padding:0; font-size:10px;"> <xsl:for-each select="channel/item"> <a href="{link}" target="_new"><xsl:value-of select="title"/></a><br/> <xsl:value-of disable-output-escaping="yes" select="description"/><br/> </xsl:for-each> </div> </xsl:template> <xsl:template match="description"><xsl:value-of select="."/><br/></xsl:template> </xsl:stylesheet>

Voilà, you have an alternative RSS-Viewer WebPart!