Sunday, January 27, 2013

Sharepoint link list content query columns

I had a request from one of the Contoso business units that they have a collection of links to physical files and actual sites that they need on every new meeting workspace site that they create using specific custom business units meeting workspace templates, with the ability to configure and update the list in a central place with real time updates.

Lucky for me SharePoint2010 provides the perfect out of the box feature to solve this.

I knew I would have to create a links list on the root/parent site that gets used for the meetingworkspace and that the template would have to be edited to add some sort of a lookup to it in conjunction with a 'content query webpart', but alas it was not so easy once everything was done I had a whole bunch of (blank) links staring back at me.

Here are a few pointers on what I did wrong and how to fix it if it ever happens to you.

First things first, create the links list. For this example lets call it 'Links'




Note: 'URL' consists of two parts an address and a description.

Step 2: is to add the contentquery webpart to the page you need it on (ps. if it’s not available you will first have to activate the appropriate feature(s))

Once added, edit the webparts settings, the topmost setting is the most important one, choosing where / what the content query is pulling for you.

In this case we will be using the 3rd option to select items from a list, clicking the brows button you will be prompted to select the list you want to query.

Now scrolling down a bit we get to the more powerful stuff

So I assumed the out of the box configuration to the title/url will just link up and work. (FAIL)

The problem is that the links list XSL saves the URL data differently than what you would expect.

Using title is null and void for the purpose of what I was trying to achieve here, using url only gave me the url and not the display title.
 
The fix, use [Custom Columns]
Done :)


Note: This trick can also be used to filter and group results.


Update: This is a must read on the simplistic power of the content query webpart.
https://www.nothingbutsharepoint.com/sites/eusp/Pages/How-to-Customize-SharePoint-List-Content-Display-using-Content-Query-Web-Part.aspx




Thursday, January 17, 2013

Fun with Meeting Workspace

A Meeting Workspace site, what is it? 
Its a Web site that is a repository for all the information and materials needed for one or more meetings. You can set up a Meeting Workspace site when you create a meeting invitation in Microsoft Outlook 2010. The subject, the attendee names, the date, the time, and the location from the meeting request are added to the Meeting Workspace site automatically by Outlook.
The first time you create a Meeting Workspace for a meeting, you must add the Meeting Workspace command Meeting workspace command icon to either the Quick Access Toolbar (QAT) or the ribbon.

 
The internet is filled with blogs showing how to work with meeting workspaces and how to add the appropriate ribbon button to outlook to use/create meetings workspaces via outlook and they all look similar to the following:
'
How to integrate with Microsoft Outlook 2010
To add the Meeting Workspace command to the QAT, do the following:
  1. Open a meeting item.
  2. On the meeting window, click the Customize the Quick Access Toolbar arrow, and then click More Commands.
  3. In the Choose commands from box, click Commands Not in the Ribbon.
  4. In the list of commands, click Meeting Workspace and then click Add.
Add a command to the ribbon To add the Meeting Workspace command to the ribbon, do the following:
  1. Open a meeting item.
  2. On the meeting window, click the File tab.
  3. Click Options.
  4. Click Customize Ribbon.
  5. In the Choose commands from box, click Commands Not in the Ribbon.
  6. In the list of commands, click Meeting Workspace, then in the Customize the Ribbon lists, click the tab and group into which you want to put the command, and then click Add. 
Note: These steps are required only one time. After you add the Meeting Workspace command one time, it appears in all meeting requests that you open.

 
More info can be found here: Use Meeting Workspaces to organize meetings
'

However that is also where it all stops....

With out going into all the endless tweaks that can be done for the actual workspace in SharePoint or endless lists of shortfalls e.g. cannot save content in template, 'folder 1' losing instance id from webparts, webparts losing there settings after saved as template to name but a few.

Even before we get to any of the wonderful things, what if 10% of Contoso's staff fell asleep during the office 2010 training and don't know how to enter the URL to start using Meeting Workspace for the first time or perhaps they are lazy or the people upstairs just don't trust end-users... well then we have an issue of how to insure that everyone is using the right URL(s).

The fix is actually very simple, they way outlook knows what SharePoint Meeting Workspace it is bound to is stored in the end-users registry settings. This setting can be preconfigured and pushed to all desired machines on the domain or can even be exported to be run by individuals.


HKEY_USERS Hierarchy:
Software\Microsoft\Office\14.0\Meetings\Profile\

Name:
MRUInternal

Type:
REG_SZ

Data: (e.g.)
https://contoso.forums.co.za/|Meetings Workspace|1033|
{00000000-0000-0000-0000-000000000000}#1ContosoExcoForumTemplate|Contoso Exco Forum Template||


Now everyone is on the same page and the magic of collaboration can begin in full swing.

Monday, January 7, 2013

AllowUnsafeUpdates, What you need to know

Knowing more about how things work is always a key to building better and more secure applications.

For an in-depth review on AllowUnsafeUpdates see Hristo Pavlov’s Blog:

http://hristopavlov.wordpress.com/2008/05/16/what-you-need-to-know-about-allowunsafeupdates/

http://hristopavlov.wordpress.com/2008/05/21/what-you-need-to-know-about-allowunsafeupdates-part-2/


In short here is how to deal with AllowUnsafeUpdates:

1) Don’t update SharePoint objects from your code behind on GET requests as if you do so your code will be exploitable via a cross-site scripting.

2) If your code is processing a POST request then make sure you call SPUtility.ValidateFormDigest() before you do anything else. This will ensure that the post request is validated (that it is not a cross-site scripting attack) and after that you will not have to worry about AllowUnsafeUpdates, because its default value will be true after the form digest is validated.


The Microsoft idea behind introducing the AllowUnsafeUpdates property is to protect YOU from cross-site scripting attacks. The way this works is that if your application is running in an HTTPContext (i.e. it’s a web part for instance) and the request is a GET request then SharePoint will refuse to do any changes unless the value of AllowUnsafeUpdates is set to true and by default it will be false for GET requests. If you try to do any updates to lists, webs or any SharePoint objects that require an SPSite to be created first, and if you don’t set AllowUnsafeUpdates to true you will get an exception.


Note: If the HTTPContext.Current is null then AllowSafeUpdates will be always true.

Note: You have to be careful because sometimes the ParentWeb of an object is not the same instance of the web you have retrieved the object from. For example when you go initialWeb.Lists[listId] you would expect that the returned list’s ParentWeb instance is the same as you initialWeb. However this is not the case. So if somewhere later in your code you go list.ParentWeb.UpdateSomething() this will not work because you have never set the AllowUnsafeUpdates property of list.ParentWeb. You have set it for your initialWeb but even that this is the same web as the list’s parent web both are different instances.