Sunday, March 13, 2011

Protecting SharePoint Library Views from being overwritten by end users

You may have experienced this before – it has happened to me in the past:

  1. You create a document using Microsoft Word
  2. To save it, you navigate to the library where you want to save it in and copy the entire URL into your clipboard (which is in fact a link to the View in SharePoint, for example, /Forms/AllItems.aspx
  3. You paste that in the MS Word "Save As" dialog and click Enter
  4. The AllItems.aspx is officially overwritten by your new Word Document and no one can see the items in the library using this view

Ways to fix the view are listed in several sites – that's easy enough to do if you are familiar with SharePoint but this is still a good hassle when your users do this from time to time.

I checked and learned that the ItemUpdating event in SharePoint is fired when you perform such an action but is not fired when you modify a View in SharePoint.

This means that if an ItemUpdating event is fired against an .aspx file which is in the /Forms/ hidden folder then it means that someone is trying to overwrite a View in this library.

I have developed a simple feature for SharePoint 2010 to catch this and cancel the update and throw an error (code below).

namespace ProtectViews.EventReceiver1

{


///
<summary>


/// List Item Events


///
</summary>


public
class
EventReceiver1 : SPItemEventReceiver

{


///
<summary>


/// An item is being updated.


///
</summary>


public
override
void ItemUpdating(SPItemEventProperties properties)

{


if (properties.AfterUrl.ToLower().Contains("/forms/") && properties.AfterUrl.ToLower().EndsWith(".aspx"))

{


//Overwriting a view

properties.Cancel = true;

properties.ErrorMessage = "Your library view was protected by Ensyst's ProtectView.\n" +


"It seems that you are trying to overwrite a view instead of saving a document in a protected environment,\n" +


"please remove the /forms/XXX.aspx from the end of the path you are trying to save to and try again";


return;

}


else

{


//Normal save

properties.Cancel = false;

}


base.ItemUpdating(properties);

}

}

}


 

The way I see it, if you wanted to properly overwrite a view with an .aspx file you have, you can just disable the feature, overwrite the file and then re-enable the feature.


This definitely helps you avoid users overwriting the views and fixing it, while the error message may not always appear it will cancel the even altogether and you can save the file somewhere else.

Enjoy…

Tuesday, January 12, 2010

Daily activities made easy(er)

I wanted to share with you some recent "upgrades" I have made, that help me in my day-to-day activities.


Generally speaking, there's nothing unique or particularly sophisticated in what I will be describing from a technical standpoint (like most of my posts), but it is the manner in-which I am utilising common tools, applications and technologies we have available nowadays that I would like to focus on.

I have a relatively poor short-term memory and as such, I learned fairly early in the game to take notes (actually, there is a famous saying used in the Israeli Air Force that goes "the opposite of Forgetting is Writing"). As a result of that habit, I found myself at the end of the day, with a truckload of papers with TODO notes leaving behind me nothing but chopped trees :-(

On a more personal level, misplacing or misreading (I have terrible handwriting) notes I made which at times affected the customer service experience I strive to give.

I also found that if I try to be smarter and type those notes on my laptop as I take them, people I hold meetings with would not take kindly to the fact that a laptop screen is between us which was reflected in their body language. To take care of that, I found that a new Tablet PC was the natural choice for me and I bought a Lenovo X200 Tablet which is a remarkable little device!

Some of you may use such devices and you might find it to be a bit tricky when it comes to managing the information captured by it, as I still use Tasks and Events like everyone else and the need to synchronise my written TODOs with my tasks was important, as was the need to have the proposed times for follow-up meetings I was agreeing to tentatively in those meetings synchronise with my calendar as placeholders or tentative meetings.

In addition to that, the need to have access to some of my notes when I am on the road (or a more relevant example, when I go to the supermarket without my laptop) on my Samsung SGH i617 running Windows Mobile OS, was a nice little add-on that I was happy to add to my new found set of capabilities.

The solution I found for these particular challenges was the new Microsoft OneNote (2010).

Let me tell you about how my routine has changed thanks to all these working together:

  • In OneNote, I have a Notebook called Clients where I have a page for each client and a subpage for each meeting I hold with this client.
  • In meetings, I type notes with the fabulous handwriting recognition capability (did I mention my terrible handwriting yet?) straight into the relevant page.
  • I mark the line I just typed as a TODO item when I want it synchronised with my tasks.
  • I mark the line I just typed as a Meeting item when I want it synchronised with my events.
  • If I take someone's contact details, I just mark that line as a Contact item and it creates a contact in my Outlook (which synchronises with our Microsoft Dynamics CRM 4.0, but I'll leave that to different post).
  • In case I have an internal meeting in the office, or a meeting that involves more than one client and I take a note that relates to a specific client, I just link the line I typed in the meeting's minutes to the relevant client notepad with a function called Linked Notes.
  • OneNote Mobile synchronises my notes (fine, my grocery lists :-) ) to my Windows Mobile.
  • I now also use OneNote as a printer when I want to add notes to printed documents or when I am on the phone and need to draw my doodles on something other than paper… :-)

The benefits this has brought me include:

  • I hardly use paper anymore so I add a little contribution towards saving the environment.
  • I don't misplace or misread TODO items I leave myself.
  • Before meeting a client, all I have to do is look at that client's page and ensure all the TODO items have been actioned properly.
  • I feel that people I meet are not affected by this method, as it is quite slim and might almost be mistaken for an actual notepad (the old-school type).

Hope this brings you something new, please add in the box below a comment if you have additional related (or not) tricks that might help me as well!

Thanks,
Shimron

Tuesday, April 7, 2009

Portals - my view...

When designing a collaboration platform, it is important to ensure that users feel as if all the information that they need and require is close by, handy and customised to suit their needs.

Open your web browser and look at your current home page!

Imagine that the next time you open it, wherever you look at the screen you will only see information you find interesting and useful.


Remember, while there are many things that could be considered interesting and useful, not all of them should appear on your home page.

By using images, charts and about 40% whitespace your page will look easier to understand and grasp at a glance.


In information sharing systems, particularly Intranets, the 3-click-rule must apply – whatever you need is never more than 3 clicks away!

In organisations that break the collaboration sites to departmental sites, the 2-click-rule should apply within the individual department pages.




What about personalisation?

Personalisation is a double edge sword, while most users would love to customise their pages to fit their needs, and while in theory that would achieve the purpose behind this point, in real life the results are usually very different.

Creating custom areas on the page is one popular approach and providing capability for users to set up a personal site which has some pre-defined layouts that include information you wish to ensure is visible for all users is also common.

There is no right or wrong approach; there is just a level of effectiveness a collaboration platform can bring, as well as an incremental/revolutionary progression.

I recommend that you start off with a platform that is presented in a manner you can control and roll it out across departments or company-wide.

Later on you can empower some key users with various levels of personalisation for pilot purposes before you mass roll out such functionality.

What do you think???