Tuesday, January 18, 2011

SharePoint 2010 - Social Tagging and Rating

What is a Tag
A tag is a word or phrase that identifies an individual piece of information according to a set of attributes or criteria. Tags make it easy to find and share information about a specific subject or task.

Social Tagging
Social tagging helps users categorize information in ways that are meaningful to them. Social tagging can improve the quality of search results by filtering against specific tags, and it can also connect individuals who want to share information with other users who have like interests.

What can be tagged?
■List Items
■Documents
■Pages (because there are documents ;)
■External pages
This means everything that has an URL can be tagged.

Tagging a List Item/ Document
By default, in a Publishing Portal, Manage Metadata feature is enabled at site collection level which introduces an association of a Site Column named "Enterprise Keywords" with each list/library item/document. In case this is not experienced on any item, the need is to enable the feauture "Enterprise Metadata and Keywords Settings" under the "Permissions and Management" group at Document Library settings page. Once this feature is activated on the document library, a new column gets added to the library columns. By default, the data referred by this column comes from the Metadata store which can be configured in Central Administration site.


Fig 2: Enable the Enterprise Keywords in a document library

Also, a user defined column can be created in any list or library. A column data type is provided in SharePoint 2010 as "Managed Metadata", which provides the freedom to the user to opt from a list of Metadata stores to tag with the column.

Fig 3: Adding a Managed Metadata column to a list

Now, all is set for tagging a list item. I have numbered down the steps to tag a list item (same is for document library item):
1. Go to the list/ library.
2. Edit any item.
3. You will have a column named "Enterprise Keywords" or as suggested by you while creating the new column.
4. Type some word in the textbox given there. You will see some suggestions are being given to you by the Metadata service, which again comes from either the default Metadata Store or the once you configured for the column while creating it.

Fig 4: Tagging a list item to a keyword

5. Based on the attributes set for the Metadata Store, the words will be resolved, if found in the store or will get added to the store, if not found.
6. Click Ok. Your item is now tagged with the value you selected and now this item/ document will be searchable based on the tag associated with it.

Tagging a Page

Fig 5: Tagging a page

Another alternate to the above option can be found at the top right corner of the page, "Tags & Notes", as shown below:

Fig 6: Tagging a Page


To tag a SharePoint page you can use the any of the above mentioned ways either from user’s context menu or from the "Tags & Notes" option available on each page of the site, as shown above. Clicking “Tag or Note this Page” opens the following dialog:

Fig 7: Add Tags to a Page

You can tag the page just like the list item before, but in addition you will get a list of suggested tags and you can mark them as private, so other user will not see them. At the bottom of the dialog you see a tag and note history. Furthermore you can add notes to the page (see in the second tab on the top).

How to tag an external page?
Since years I miss a tool from Microsoft to centrally manage bookmarks and I believe I’m not alone. To tag external pages you have first to add a link to the SharePoint tagging dialog to your browser’s favorites:


Fig 8: Tagging an External Page

This adds the “Tags and Noteboard” bookmark (JavaScript) to your browsers favorites list. Now you tag an external page like this:

Fig 9: Tags and Noteboard in favourites

Clicking to the “Tag and Noteboard” brings up the same dialog as in the previous example for a SharePoint page. You can tag and write notes as usual.

Tag Cloud Web Part
For sure you want to use your tags to navigate and filter content. For this reason there is now a tag cloud web part included in SharePoint 2010.




Fig 10: Tag Cloud web parts

My Tags and Notes
You can manage your tags globally as shown below.



Fig 11: My Tags and Notes

Ratings
One of the main features of SharePoint is the document libraries and if used correctly they can get very full, very quickly. How can we make it easier for users to find the best articles within a large document library.

One of the ways is to use ratings, this feature in SharePoint 2010 lets users rate documents and then you can sort the document library on the ratings field.

Enabling Ratings
Go to the document library, see the ribbon and click on Library Settings

Fig 12: Document Library Ribbon with Library Settings option

Click on the Rating settings option


Fig 13: Enable ratings in a Document Library

Click the Yes option and then click OK


Fig 14: Select Yes and then OK

NOTE
For this to work you must have a User Profile application service connection associated with the web application.

Rating Documents
Now when we return to the document library, the rating field is enabled


Fig 15: Document Library with Rating column

To rate an item simply drag your mouse over the number of stars you want to give it and then click the left button


Fig 16: Rate a document

NOTE
If you have rated a document and then wondered why it disappears, well that’s easy. Part of the user synchronisation connection service is a timer job that runs every hour to update any ratings that have been added. You can run this manually from the central admin if you so wish.

So, that is all for this while. Will be back again with some other interesting features like Metadata Management aka Term Store Management tool provided by Microsoft in SharePoint 2010....

Monday, November 9, 2009

You wanna handle page content based on Permissions..!!!.. Tell me....

To start with this post implementation one needs to have a little less known built in XSLT function called ddwrt:IfHasRights()) and some Conditional Formatting logic.
Simply select the text or mark-up inside the data view web part and then
Click on Conditional Formatting option in the Task Panes menu
In the Condition Criteria dialog box select Advanced and in the Advanced Condition dialog box change Select a function category to All
Find and insert the IfHasRights() function by double clicking on the Select a function list
Use a single Permission Mask for example 4 IfHasRights(4) to only make the mark-up or text visible when the user has edit rights on the page\item
Following is a list of Permission Masks for the build in permissions
1. ViewListItems – 1
2. AddListItems – 2
3. EditListItems – 4
4. DeleteListItems – 8
5. ApproveItems – 16
6. OpenItems – 32
7. ViewVersions – 64
8. DeleteVersions – 128
9. CancelCheckout – 256
10. PersonalViews – 512
11. ManageLists – 2048
12. ViewFormPages – 4096
13. Open – 65536
14. ViewPages – 131072
15. AddAndCustomizePages – 262144
16. ApplyThemeAndBorder – 524288
17. ApplyStyleSheets – 1048576
18. ViewUsageData – 2097152
19. CreateSSCSite – 4194314
20. ManageSubwebs – 8388608
21. CreateGroups – 16777216
22. ManagePermissions – 33554432
23. BrowseDirectories – 67108864
24. BrowseUserInfo – 134217728
25. AddDelPrivateWebParts – 268435456
26. UpdatePersonalWebParts – 536870912
27. ManageWeb – 1073741824
28. UseRemoteAPIs – 137438953472
29. ManageAlerts – 274877906944
30. CreateAlerts – 549755813888
31. EditMyUserInfo – 1099511627776
32. EnumeratePermissions – 4611686018427387904
33. FullMask – 9223372036854775807

For example,



Another approach for the same problem set is as follows :

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControlName″ PermissionsString=”” runat=”server”>

The markup that needs to be security trimmed goes here.

</SharePoint:SPSecurityTrimmedControl>
The above mentioned permissions acan be used as trimmer parameter (you can add multiple using commas).

Tuesday, June 9, 2009

Content Editor Web Part Magic - 1 : Add Outlook Inbox on web page using Content Editor Web Part

A lot has been talked about the fascinating features of Content Editor Web Part (CEWP) in MOSS 2007. Have you thought about its features like get your java script added on the share point page and do whatever you like (if attainable in java script!!) or have your mind horses galloped to the field to get your Outlook configured on the web page with a blazingly accountable performance. I have said this because already there are OOB web parts available to drag items from you Outlook account and get them stitched on your web page. But going that way may be too much costly in terms of performance (the most important thing for you clients..!!. No doubt every lacking thing from your side is on priority of client’s wish list!!).
So cutting the crap now and coming to the point: Using java script to yank the items from your Outlook account and get them travel to your web page is as simple as reading this blog. So for your convenience (prime concern for this blog owner), I have summarized the steps as below:
· Add a new web part page in your share point site, say Outlook.aspx.
· Edit the page and add a CEWP on to that.
· Edit the CEWP using the Edità Modify this web part sort of thing.
· Open the Source Editor window by bashing the “Source Editor…“ guy there.
· Okay the billion dollar point, Add the below code in the window and Save.

< language="javascript" type="text/javascript">

function getNewEmail() {

try {

o = new
ActiveXObject("Outlook.Application");

if(o) {

mailFolder =
o.getNameSpace("MAPI").getDefaultFolder(6);

//You could also use custom forms like
//IPM.Note.CustomForm

mailItem = mailFolder.Items.add("IPM.Note");
mailItem.Display(0);

}

}

catch(e) {

window.status = e.Message;

}

}

< /script>

< type="button" title="Send new email" value="New" onclick="javascript:getNewEmail();">

< classid="CLSID:0006F063-0000-0000-C000-000000000046" width="100%"> < name="Folder" value="Inbox"> < /OBJECT>

< classid="CLSID:0006F063-0000-0000-C000-000000000046" width="100%"> < name="Folder" value="Tasks"> < /OBJECT>

· Now close your eyes and count to 3…!!! .
· Open your eyes and see what you have done..!!!??. The “Inbox” and “Tasks” are welcoming you on your web page.
· Control your ecstasy and Click OK there in the right hand side.
· If this is a Publishing Page, publish it or if it is a team site, then Exit edit mode.
· Wooo... hoooo… TADAAAA….!!!. You can see the “Inbox”, “Tasks” have been fetched from your Outlook account and are served to you on your page..!! What a mind blowing job you have done…. ??
· OK... do you see something else there? A poor guy... a “New” button?? Don’t get confused... it is there because of you… and for you.. Since this activity is not able to provide you everything that an OOB web part can but yes it gives you at least some hold to you to have done your customizations.
· So that’s all form me... what else are you waiting for??? Go and play with your Outlook now…!!
You rock…!!!


Friday, May 22, 2009

Pre compile your website and publish it without source code or markup

  • Brief introduction to building versus pre compiling
    If you build your web application in Visual Studio you'll get at least a few binaries, or .dll, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is requested for the first time after restart. Unless you deploy your web application in a precompiled state that is!
  • Pre compile your web application before deployment
    When you precompile your web application the following takes place:
    1. All markup files (.aspx) are stripped of their content
    2. All web service files (.asmx) are stripped of their content
    3. All code-behind files (.cs) are removed
    4. All user control files (.ascx) are removed
    ...and some other things
    This means that you will be able to deploy your website entirely without readable markup or source code.
    You still need all the markup files in the correct places, but they will no longer contain any actual markup. So, in the future you won't have to worry about updating .aspx files - unless new ones have been added to the web application.
  • How to pre compile your website
    In order to pre compile your web application you need to use a simple command prompt command. If you wanted you could add this command to a post-build event to automate the process.
    The pre compilation is carried out by the aspnet_compiler executable located in your .NET installation folder. If you run the Visual Studio command prompt you won't have to worry about that though - the path variable is then set so that you can execute the aspnet_compiler executable regardless of what folder you are in.
    If you use the standard command prompt (cmd) you'll have to switch to the correct .NET installation folder, for example:
    > c: > cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

    So, let's say I have a website located in C:\MyWebSite. In order to precompile this website I use aspnet_compiler and specify a target folder for the precompiled output:
    > aspnet_compiler -p C:\MyWebsite -v / C:\MyPrecompiledWebsite
    The C:\MyPrecompiledWebsite will now contain a precompiled version of the web application. All markup and web service files will now be empty except for a text saying (my emphasis): "This is a marker file generated by the precompilation tool, and should not be deleted!"
    You are now ready to deploy!
  • Additional information
    For more information on different precompilation scenarios and techniques, see:
    ASP.NET Precompilation Overview
    How to: Precompile ASP.NET Web Sites
    How to: Precompile ASP.NET Web Sites for Deployment

Please make a note that this type of deployments are really impressive in scenarios where the site is finally ready to move on your production environment and the modifications are not so frequent on you web site. Also, another case may be if you don't really want to give your code to the client ;).

Tuesday, May 19, 2009

Custom List Paging in OOB way

using (SPSite mySite = new SPSite("site url"))
{
using (SPWeb myWeb = mySite.OpenWeb())
{
SPList myList = myWeb.Lists["List Name"];
if (myList != null)
{
SPQuery myQuery = new SPQuery();

myQuery.Query = "";

myQuery.RowLimit = 10;

// Set the paging information with query object in case it is required.
string strPageInfo = string.Empty;

// Prepare the pageInfo string for Previous Page.
if (strEvent == "PREVIOUSPAGE")
{
strPageInfo = "Paged=TRUE&PagedPrev=TRUE&p_" + strSortFieldName + "=" + strSortFieldLastValue + "&p_ID=" + strPageID;
myQuery.ListItemCollectionPosition = new SPListItemCollectionPosition(strPageInfo);
}
// Prepare the pageInfo string for Next Page.
else if (strEvent == "NEXTPAGE")
{
strPageInfo = "Paged=TRUE&p_" + strSortFieldName + "=" + strSortFieldLastValue + "&p_ID=" + strPageID;
myQuery.ListItemCollectionPosition = new SPListItemCollectionPosition(strPageInfo);
}

SPListItemCollection myItems = myList.GetItems(myQuery);
if (myItems != null)
{
// Gets the result set
DataTable dtResult = myItems.GetDataTable();
}
myQuery = null;
myList = null;
}
}
}

Notes:
· strEvent (string) – variable that indicates which event is reuiured “NEXTPAGE” or “PREVIOUSPAGE”.
· strSortFieldName (string) – The list field name based on which sorting is required.
· strSortFieldLastValue (string) – The sorting list field’s value corresponding to the last row being displayed at your UI (eg. GridView).
· strPageID (string) – The list field “ID” value for the last item on UI (eg. GridView).
· isAscending (string) – “true” or “false”, indicates the order of sorting.