Wednesday, January 25, 2012

Hide View All site content


to hide view all site content,

edit the page, add a content editor Webpart 

in source Editor, copy the below code, and save it. 


<style>
.ms-quicklaunchheader {
display:none;
}
</style>

Thursday, January 12, 2012

How to move/migrate SharePoint list items/documents and preserve metadata properties

Usually, when you want to move documents or list items from a source to destination list, we follow the following methods
  • Opening in windows explorer and copy pasting the documents
  • Saving the source list as template including content and then recreating the list in destination using template
But both above process when we move we have the below drawbacks
  • The metadata properties more importantly the Modified date stamp and created date stamp are not preserved
  • For issue tracking list, where we usually dont have the option to save as template including content cannot move items.

There is an alternate method to achieve moving the items from source and destination list, same time preserving the meta data properties.

1. Create a blank list of document library/custom list etc in the destination site. No need to create the custom columns etc, the move process will take care.

2. Access the Site and Content structure  from Site Actions button or from site settings ->Site administration ->content and strcuture


3. Select the list or library in the list and go to all items view and select all the items. In toolbar, actions , click on "Move".




4. You wil receive a pop up asking to select the destination list. Just select the list you have created and ok.

Done. Now you can see all the items are moved along preserving the time stamp. 

Note: If you get any errors while moving the items, the alternate way is save the source list as template excluding content and then recreate it in destination. This will preserve the structure in source.

Also do note that, if source has versioning enabled, then destination should also have versioning.
If it has look up columns do manage to make lookup work by created the dependency lists in destination also.

You can move the dependency list using the same process first and then the actual list.

Hope it helps you!!


Thursday, January 5, 2012

Avoiding Recursion in Event Receivers

While writing the Event Handlers, generally we will have the requirement as checking few of the field values and updating other fields accordingly.
But when you try updating the item again the event handler will fire again and if you observe the version history of the item, the change made by user which triggered the event receiver will be registered as one version and the one triggered by the code will be as another version and also if you see the modified person will be admin.

By adding few lines of code we can avoid the recursion of event firing and the redundant versions.

item[fieldname] = fieldvalue;
this.DisableEventFiring();
item.SystemUpdate(false);
this.EnableEventFiring();

By disabling event firing before update, the recursion will be avoided. And by SystemUpdate(false), ensures that no version is created by this update and also user can see the update as his update rather than Admin's.