Wednesday, September 14, 2011

SharePoint 2010 and Taxonomy API’s



Term Store, Term Sets and Terms....are good but what if i want to use them in place of list columns (Creation of a complete list for a single column value like Countries name and use this list as a reference as lookup column, in InfoPath column as source...and many more....). How i will get the term store on some places where i can refer a list simply by using a web service or rest service...


How you can utilize the SharePoint API to programmatically work with Taxonomies and create terms and fetch the terms in your term store. This should give you some nice ideas on how to get going!


1. Dll Reference:


Microsoft.SharePoint.Taxonomy


You’ll find this reference here:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Taxonomy.dll



2. Namespaces:

So, the first thing we would like to do is to learn how we can read the taxonomies we’ve got in our store. To do this, we utilize Microsoft.SharePoint.Taxonomy.
There’s a few good-to-know classes in this namespace that we’re going to work with:
The above classes are stated in their hierarchically correct order, meaning means that you start out with the TaxonomySession which contains the TermStore, which contains the Groups.. and so on.


Reading the Metadata store (Managed Metadata Service):


Now lets generate the XML tree with it.


protected  void  Page_Load(object  sender, EventArgs  e)
{
SPSite  thisSite = SPContext .Current.Site;
TaxonomySession  session = new  TaxonomySession (thisSite);

TreeNode  treeNode = new  TreeNode ();
treeNode.Text = "Corporate MetaData" ;
tvMetadataTree.Nodes.Add(treeNode);

foreach (TermStore  termStore in  session.TermStores)
{
var  tsNode = new  TreeNode (termStore.Name, null , null , "" , null );
treeNode.ChildNodes.Add(tsNode);
//treeNode = tsNode; 

foreach (Group  group in  termStore.Groups)
{
var  node = new  TreeNode (group.Name, null , null , "" , null );
treeNode.ChildNodes.Add(node);
//treeNode = node; 
foreach (TermSet  termSet in  group.TermSets)
{
node = new  TreeNode (termSet.Name, null , null , "" , null );
treeNode.ChildNodes.Add(node);
treeNode = node;

foreach (Term  term in  termSet.Terms)
{
AddTermSet(term, treeNode);
}
}
}
}
}

void  AddTermSet(Term  term, TreeNode  treeNode)
{
var  node = new  TreeNode (term.Name, null , null , "" , null );
treeNode.ChildNodes.Add(node);
treeNode = node;

foreach  (Term  t in  term.Terms)
{
AddTermSet(t, treeNode);
}
}



The end result will be a simple TreeView control filled with the Metadata structure from the store, looking something like this:

Thursday, September 8, 2011

By Code delete All Old Versions from SharePoint 2010 Document Libraries

How many versions of a typical document do you need to keep? 5? 10? 100?

SharePoint content databases often get cluttered with redundant versions of the same documents. In some cases, I've seen presentation libraries with less than 10 GB of active content, but hundreds of GBs of content due to gradual changes.

If you're ready to clear out old versions, SharePoint 2010's Management Shell makes it easy. The script below will iterate through all lists and update them to keep only the last 2 copies. It will also loop through and delete unneeded versions.

Get-SPWebApplication
Get-SPSite -Limit All
Get-SPWeb -Limit All
ForEach-Object {ForEach($list in $_.Lists){If($list.EnableVersioning -eq $true){$list.MajorVersionLimit = 2; $list.Update(); ForEach($item in$list.Items){$item.URL; $item.SystemUpdate()}}}}

You can see that it...

  • Loops through all web applications
  • Loops through their site collections
  • Loops through their webs
  • Loops through their lists
  • If versioning's enabled, it sets the major version limit to 2

In order to remove old versions, it needs to loop through each item and perform a system update

The script can be easily amended to deal with only specific site collections / libraries. To keep a different number of versions, modify the MajorVersionLimit variable above.


Cheers!!!

Wednesday, September 7, 2011

Site and Sub-Site GUID's with STSADM

The following command displays the GUID's of all the Site Collections, root site and all it's sub-site on command prompt using stsadm utility. Same can also be achieved using PowerShell.

Displays the IDs and site map status for all site collections and subsites in the content database.
stsadm -o enumallwebs -databasename
 
Note: Replace with actual content database name. Go to Central admin > content database for the particular web application.
 
Cheers!!!

Document Sets in Sharepoint 2010 – Limitations


To resolve the list threshold issue for a list holding more then 23000 items, i was in process of using the Document Sets for the entire library and categorized by the content types.

I got to know few limitations with Document sets as i was also planning the Record Management Capabilities for these records as well.

Here we go....

- Document Sets are only available in SharePoint 2010 Server and are not part of the SharePoint Foundation 2010. This also means that the programing object model (SPFolder) is part of the SharePoint 2010 Server API and not available in the Foundation OM.

- You cannot create a Folder within a Document Set. Beware that the UI will not prevent you from doing this, but folders are not supported and likely will not work as you think they should.

- You cannot create metadata navigation in a Document Set.

- Since Document Set is being treated as a Folder, which is treated as such when you deal with operations like Record Management and File Upload. It’s a little bit inconsistent from the document-centric point of view.

- You cannot send a Document Set larger than 50MB using the Send To command.

- In general, beware when you create and use very large Document Sets (thousands of items), as the limitation and performance factor of viewing and displaying the list will be a factor.


- Download the entire document set. This is a very useful feature that did not make it into this release of SharePoint 2010. If you select the entire document set, you will notice that the “Download a Copy” button is grayed out. Fortunately, there are instructions available to add a custom button in the ribbon to add this feature.

Cheers!!!!!!!!!!!!

Monday, September 5, 2011

My Experience with SharePoint 2010 New Features


My experience with SharePoint 2010 and My Experience with Truth  by GandhiJi :)

I’ve summarized my personal favorite features in SharePoint 2010.

1) Sites (Web Experience)

Microsoft have incorporated the Office Ribbon within SharePoint 2010. Not only does this allow, web editing ‘in place’ ( WYSIWYG, ‘Drag and Drop’ etc - Like many other site builders have allowed for years!), but provide support for multiple browsers.

Workspace (previously called Groove) allows offline working and synchronization. It also supports advanced features like bringing external business data offline. Its also smart enough to sync changes and not entire files!

Office Web Apps (Word, Excel, PowerPoint, OneNote etc) now means that not only can multiple people work on the same document.(Different people can work on different sections at the same time) Plus, you no longer have to have the latest version of Office stored locally on your laptop or PC. Its all done through the browser.

SharePoint Workspace Mobile Client provides a clean way to view SharePoint on mobile devices and also allows offline access. This Allows search and navigation on content within a browser

2) Communities (Enhanced Social Networking)

In true Web 2.0 fashion, Collaborative Content of Blogs, Wikis, Calendars, Discussions, Tasks, Contacts, Pictures, Video and Presence.

Social Feedback allows users to provide, Bookmarks, tagging and Ratings on ALL content types. Social Tagging allows all users to add tags to all forms of content.

User Profiles can now reflects expertise via Tagging or even make recommendations based on an Outlook or OCS plug-in that crawls your outbox and picks up the subject matters you most talk about. (This is ‘opt-in ‘of course, so your boss won’t automatically know you are an expert on Fly Fishing due to your outbound emails)

MySites contain enhanced Newsfeed (like the Status update on face book), personalized content and Quick Access to Content and social network. This also encompasses a facebook type ‘wall’ for letting users interact with each other the way they do in their personal lives.

People Connections show online presence and also allow you to search colleagues using an Interactive Organization Browser (using Silverlight)

3) Content

One of the most exciting features that I feel the business will really appreciate is Top down Taxonomy / Bottoms Up Social Tagging. Essentially, this lets Users (rather than the publisher) define what the content is (So someone might tag this blog post as “SharePoint 2010”, even though the title is completely different.) This means that content should be easier to find as the users are the ones labeling it.

Large Lists and Libraries now allow tens of Millions of documents to be stored (Big failing in MOSS 2007 was it struggled at 2,000+). Enterprise Metadata generally means it’s easier to apply Metadata (tags, keywords) and thus easier to find information.

Digital Asset Management now allows Thumbnails, Metadata and ratings for images & Video Streaming from SharePoint.

Governance & Records Management Features now make it a lot easier for compliance people to do their job using SharePoint.

4) Search

For me, this is the best and most useful component of SharePoint.

SharePoint 2010 now provides a completely Interactive Search Experience. Some much needed things like automatic search query completion (like Google or Bing), Spell Checking and Wild Cards (“Did you mean?”) generally make it easier to find stuff!. Another massive factor is generally Connectivity is a lot better.

Business Connectivity Services (BCS) replaces the Business Data Catalogue and makes it easier to both search external databases, but also provides the ability to ‘read and write’. The great thing about this also is you can create Search Connectors without writing any code using SharePoint Designer. (Free tool that comes with within SharePoint).

For Enterprise customers, FAST can be utilized (which is the mother of all search!). This will allow users to search EVERYTHING! Including multiple platforms, databases and other external systems used across the organization.

There is a lot more relevance in the search results now, as this includes social data such as tagging and usage. People Search incorporates Social Networking algorithms, so results are displayed dependent on the degrees of separation between you and your searches. (Think LinkedIn style!) A Phonetic Search Algorithm for finding names is pretty cool also.

Increased Scale and Platform Flexibility now also makes it quicker and easier to search Millions of items.

4) Insights (was B.I)

Insights will be much loved by the accounting types and generally anyone that is swamped by reporting numbers who needs to publish the data in an elegant, professional presentation style. Excel Services allows user rich visualizations such asHeat Maps and Spark lines present data. Think of a map that Police Forces could use that plots where Anti-Social behavior is happening based on an Excel Spreadsheet and you get the drift.

Performance Point Services now gives enhanced scorecards, dashboards KPI’s & navigation features. SQL Server services such as Analysis Services and Reporting Services are now easier access for reporting.

Gemini is the name for the memory database that allows reporting on Excel Spreadsheets containing millions of lines of data without needing a developer.

Visio Services – Allows rich user rich diagrams to be produced within SharePoint and also includes SharePoint workflow designer. Very handy for process mapping!

5) Composites (Custom Solutions for SharePoint)

As I said, Microsoft are really empowering the Power users and composites is a handy toolkit that gives competent users the tools they need to build their own applications without IT. These are the main ones.

SharePoint Designer

• Office Ribbon

• User Customization

InfoPath Forms Service

• Easy way to build forms

Access Services

• Lets you create and publish database applications

Sandbox Solutions

• Allows custom code to be produced in local sites without affecting the whole SharePoint Platform E.G Webparts, Event Receivers. Same will apply for “SharePoint Online”.

Business Connectivity Services (was BDC)

• 2 Way Connectivity


Cheers!!!!

8 Great Tips to get the most out of SharePoint


Wanna Use SharePoint....What's User Pain...What about User adoption...once you are ready with it....???? So lots of things to discuss here....User Training....what to tell them and what's not....lot's of thingssssssssssssss................So how to manage it.....here are few tips.....

Don’t let IT Run the project – SharePoint is a business facing application. Unless there is a fresh installation needed, try to keep the project run by someone in the business who understands the challenges in the business rather than of the technology.

Requirements gathering – Ask end users what they want by actually asking the question ‘tell me about the challenges in your business’. Count the blank looks on people’s faces when you ask ‘tell me what you want SharePoint to do.

Custom code – There is always a time and a place for this but avoid wherever you can. For every 5 days of development, the same can be achieved with configuration in 1.

‘Out of the box’ Features - Get to know all of the features that are in SharePoint. Knowing what the product can actually offer can avoid custom code!

3rd Party Products – SharePoint, like all systems, has its shortfalls, but there are thousands of products that can be bolted onto SharePoint to address these. These costs a fraction of the cost of developing from scratch and are supported also.

Micro-Projects - Wherever possible, try to deliver SharePoint offering in small chunks. This will make SharePoint become viral and also make it easier to improve on each piece that you deliver. Hard to do with a ‘big bang’ approach.

End User Training - Train Train Train – Allow a decent budget for training end users on how to actually use SharePoint. How will people use the tool if they don’t know how to?

Support - Log a ticket approach doesn’t work with SharePoint. Try to identify the ‘power users’ that can be accessible to help the business users.

Cheers!!!!!!!!!

Friday, September 2, 2011

Try querying lists with REST and ListData.svc in SharePoint 2010

So ready with 1 more.... I just started using the REST for one of my application and found it's pretty good and simple...

When you are getting started, the first thing you want to do is check and see if you have ListData.svc up and running. Like any SharePoint web service, it’s located in the _vti_bin folder of any existing site, so it will work with items relative to that site. Here is what a typical URL might look like.


Try hitting that URL on your SharePoint 2010 server and see if it works.  There is a good chance that you will get a 404 error.This happened to me, so I did some searching and found Rob Garret’s post stating to go out and install ADO.NET Data Services 1.5 CTP 2. There are a few choices, but I have seen others recommend you go with the runtime only. I had issues installing the full package. Once you have it installed, it still didn’t work for me, so I rebooted my server and everything worked fine when it booted back up. My guess is you probably could just reset IIS though.

To get the data for this list via REST we simply just add the list name to the URL. In my case the name of the list is called Tasks. Here is what the URL would look like.

http://Server Name/_vti_bin/ListData.svc/

As you can see in the content element, we can see the various site columns on a particular list item. Of course, there is more we can do with REST than just view everything in a list. If you want a specific item, you can use parenthesis and specify an indexer. Note that it is unit-indexed, not zero-indexed.



http://Server Name/_vti_bin/ListData.svc/()

However, when you do this, Internet Explorer will give you an error that it cannot display this feed.



Not to worry though, if you view source, you still have a working XML document. It will pretty much look like the one above minus the initial feed information. You can take the query above and go one step further. Say, you just want to know the status for a specific task (note that the site column is actually called StatusValue here), you can simply add it to the URL like this.

http://Server Name/_vti_bin/ListData.svc/()/()


The last thing I will cover is simple queries. You can do this with $filter. There are a number of operators you can use here, but the one I will start with today is eq (or equals). For example, say I want to see all tasks that are completed, I would use a URL like this. Put any literals inside quotes.



You can also use various other types of predicates, such as ne, gt, ge, lt, le, and, or, not, etc. What each one does is probably pretty obvious, but if its not take a look at this MSDN reference for more information on the various filters and parameters you can use. Skip the code stuff at the begging and scroll down a bit to find the good stuff. This is a good start to working with REST in SharePoint, but this really is just the tip of it. What you are learning here isn’t really just specific to SharePoint but it applies to anything you do with ADO.NET Data Services, so it might be useful elsewhere later.