Thursday, April 15, 2010

Speaking at SharePoint Saturday DC on May 15th 2010



Title: Speaking at SharePoint Saturday DC on May 15th 2010

Topic: SharePoint 2010 Sandboxed Solutions


Location: NVCC Community Cultural Center Annandale, VA

Saturday, April 3, 2010

How to use Rating Control in SharePoint 2010

Title: How to use Rating Control in SharePoint 2010

Details: Some thing and finally some thing every one really wanted. Either you download code from codeplex or use any 3rd party controls - its takes about week or more for you to create a Rating Control that is customized to your needs. Now, we have this out of the box in SharePoint 2010 and here is how you use it.

How-To: Lets begin with setting up Rating Control for a Custom List first.
Step # 1 Enable / Start the 'User Profile Service' from the CA > System Settings > Servers > Manage services on server ( by default it is Started ).
Step # 2 Under CA > Monitoring > Timer Jobs > Review Job Definitions > look for 'User Profile Service Application - Social Data Maintenance Job' and

'User Profile Service Application - Social Rating Synchronization Job'.
These jobs are scheduled by default to run every 1 hr. 


Step # 3 For our convenience and testing, schedule both these jobs to run every 1 min as shown below.
Also do the same for
'User Profile Service Application - Social Rating Synchronization Job'


Step # 4 Ok you are now all set. Go to the List level ( your desired List / Doc Lib ) and get to the List Settings
Step # 5 Select the Rating Settings on the General Settings option and choose the option 'Yes' for 'Allow items in this list to be rated?'
Step # 6 Once you choose this option, 2 new columns will be added to your list as shown below
Rating (0-5) will give you the 5 star rating asynchronous control that you can rate any item for.
Number of Ratings will display how many unique users rated the item.

Remmember that if same user rates twice, it will override his / her previous rating
( and will not aggregate ).

Rating control will average ratings of unique users rating on item basis.
Step # 7 User ratings are collected asynchronously as shown below.
Step # 8 Once you submit rating, you will be also shown the success message.
Step # 9 Wait for a minute since the timer jobs is set to run for every 1 min as configured earlier. View the list webpart and notice that the ratings will be changed.
Step # 10 Perfect! Lets now see how to use this Rating Control on a Page. First we need the Page level register tag.
<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Step  # 11 Once you register the Control Tag, use the below control code and add it to the PlaceHolderMain section.
Make sure that the FieldRef Name matches the column name. You are all set now.

<SharePointPortalControls:AverageRatingFieldControl id="PageRatingControl" FieldName="Rating (0-5)" runat="server" />

Friday, April 2, 2010

Using Custom Actions in SharePoint 2010

Title: Using Custom Actions in SharePoint 2010

Details: Using Custom Actions in SharePoint 2010 is not different as you create them in either WSS3.0 / MOSS 2007. In this post I will run through the sample of creating your own Custom Group and then a Custom Action link under it. Now before we proceed, I created a very nice pic of mine and sized it to 48x48 and copied it to the 14 hive / Template / Images folder ( named as SiteSettings_SriniSistla_48x48.jpg in this case ). Alright, now lets proceed for few steps.
Step # 1 Create a folder ( MyCustomActions in my example ) with a proper name of your choice
Step # 2 Add a new file to the folder and name it as Feature.xml
Step # 3 Add the content as shown in below code and customize it to your needs. Well, notice that this feature is Scoped to Site and you can create a feature for any scope based on where you want to have the Custom Action.
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
 ActivateOnDefault="FALSE" 
 AlwaysForceInstall="FALSE" 
 AutoActivateInCentralAdmin="FALSE" 
 Description="Will Create a Section and Link to my Blog" 
 Hidden="FALSE" Id="90C924A7-32F7-4C19-BD4C-AF49EF0563A9" 
 Scope="Site" Title="My Custom Actions">
 <ElementManifests>
 <ElementManifest Location="MyCustomActions.xml" />
 </ElementManifests>
</Feature>
Step # 4 Create another file in the same folder ( myCustomActions.xml in my example ) and name it as Elements.xml or of your own choice
Step # 5 Add the content as shown in below code and customize it to your needs.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomActionGroup Description="Srini Sistla Exclusive Custom Group" Id="SriniSistla" Url="/_layouts/images/SiteSettings_SriniSistla_48x48.jpg" 
Location="Microsoft.SharePoint.SiteSettings" Sequence="111" Title="Srini Sistla Blog Details">
  </CustomActionGroup>
  <CustomAction GroupId="SriniSistla" Id="UserInterfaceCustomActions.SiteSettings"  Location="Microsoft.SharePoint.SiteSettings" Sequence="106" Title="Blog  Link">
     <UrlAction Url="http://codename-srini.blogspot.com" />
  </CustomAction>
</Elements>
Step # 6 Now, notice that I have a CustomActionGroup created first ( with Id = SriniSistla ) that I will use it in my CustomAction Section. You can create of your own choice in this case.
Step # 7 Once you have everything in place, copy this folder to 14 hive > Template > Features.
Step # 8 I am happy for now in still using STSADM commands and I will go ahead and use the Install Feature Command here.
stsadm -o installfeature -filename MyCustomFeature\Feature.xml
Step # 9 You can as well activate the feature using Stsadm itself, however you can as well go and activate your feature from the Site collection features link under Site Actions > Site Settings > Site Collection Administration as shown below.








Step # 10 Once you activate the feature, you will find the Custom Actions group and the Custom Actions Link on your site actions > site settings page as shown below.
















So far so good. Notice the GroupId="SriniSistla" in my example. If you want to add to an already existing out of the box groups use below GroupId's.

First, to Add your Custom Actions under Site Actions > Site Settings Page set the Location="Microsoft.SharePoint.SiteSettings" and
GroupID="Customization" to add under 'Look and Feel Section'
GroupID="Galleries" to add under Galleries'
GroupID="SiteAdministration" to add under 'Site Administration'
GroupID="SiteCollectionAdmin" to add under 'Site Collection Administration'
GroupID="UsersAndPermissions" to add under 'Users and Permissions'

for entire Custom Actions list, refer to the msdn site here.
have fun.