Sunday, January 25, 2009

Custom Feature - Content Type

Everyone has built a simple feature either for event handling purposes or site action menu but how about creating and deploying custom feature on ECB menu and based on content types.
Here is a simple feature manifest:

<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="5DFD12AF-D0AA-4c63-8FB8-C49DB1191083"
Title="My Site Content Type Feature"
Description="Adds my Content Types."
Scope="Site"
Version="1.0.0.0">
<ElementManifests>
<ElementManifest Location="ContentTypes.xml"/>
</ElementManifests>
</Feature>

Here is a elements manifest which adds ECB menu for a infopath form content type:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="NIBR.NimbusStatusReport"
Location="EditControlBlock"
Title="(Nimbus) Display in SharePoint...."
Sequence="10"
RegistrationType="ContentType"
RegistrationId="0x010100AF717F1A25C33E438J00D81D31F0A176">
<UrlAction Url="{SiteUrl}/Pages/StatusReportViewer.aspx?item={ItemUrl}"/>
</CustomAction>
</Elements>


The stuff worth noticing here is the RegistrationType and RegistrationId attributes
RegisterationType should be set to ContentType and RegisterationId should be set to the document content type or the parent contenttype if you want to enable the ECB menu for all items deriving from the parent Content Type.
To create a new ID for a content type you can follow one of two possible conventions:

[parent content type ID] + two hexadecimal values (different from "00")
[parent content type ID] + "00" + hexadecimal GUID
Usually the first convention is used by SharePoint for the default content types included in SharePoint.

Example:

0x (System)
0x01 (Item Content Type)
0x0101 (Document Content Type, child of Item Content Type)
0x0120 (Folder Content Type, child of Item Content Type)

Once we are done with building the feature it's time installing and activating. Follow the following stsadm commands to get it in place.

installfeature:
stsadm.exe -o installfeature
{-filename |
-name }
[-force]

activatefeature:
stsadm.exe -o activatefeature
{-filename |
-name |
-id }
[-url ]
[-force]

uninstallfeature:
stsadm.exe -o uninstallfeature
{-filename |
-name |
-id }
[-force]


It's all done !! Enjoy your first feature

Sunday, November 30, 2008

MOSS - Display Column based on Security

What if you want to enable a column only if the user has permissions?
Now you might have worked with Item Level permissions but what when you wanna show the record to all users but just disable a COLUMN to particular users.

For e.g. for a SharePoint library which contains infopath form you want to display all forms to all users but only let few users EDIT them.
All this is done in SharePoint designer. Convert your ListView to Data view and then follow the steps below:

Create new site column (hyperlink) in DataView:

<a href="http://yourinternalsite/_layouts/FormServer.aspx?XmlLocation=http://yourinternalsite/subsite/FocusReports/{@FileLeafRef}&OpenIn=Browser">Edit</a>

And add the following code to the column created above:

Show/Hide Edit column based on security (read only users will not see the column)
<xsl:if test="ddwrt:IfHasRights(4)">

Isn't it simple !

Enjoy programming !!

Saturday, November 1, 2008

MOSS - Group Items with Item Count

Many times you might have been asked to change the SharePoint Library views with new columns, calculated columns etc. This technique explains how you can group the items based on a column and provide the item count under that group in the header.


So essentially something like this:

+ Project: XYZ (15 items)
+ Project: ABC (25 Items)


Its pretty simple to achieve the grouping but a small trick to display the item counts.

First open your site in SharePoint Designer and go to the Page view (mostly in the /POages directory)
Then right click on the ListView and convert to DataView.
Go to DataView Properties-->Groupby-->Collapse header
Then in the name column enter the following:

<xsl:value-of select="$fieldvalue" > : <xsl:value-of select="count($nodeset[*[name()=$fieldname]=$fieldvalue or ($fieldtype!='isodatetime' and @*[name()=$fieldname]=$fieldvalue) or ($fieldtype='isodatetime' and ddwrt:GenDisplayName(string(@*[name()=$fieldname]))=$fieldvalue) or (not(*[name()=$fieldname] or @*[name()=$fieldname]) and $fieldvalue = ' ')]/@ID)" />


--------- BANG !!! There you go... as easy as it gets

Thursday, August 7, 2008

Olympics Schedule

4 Years Wait !!


Olympic Medal winners at NBC Olympics.com!

Friday, July 18, 2008

Worth Noting ----- ASP.NET MVC Preview 4

I blogged earlier regarding MVC new release and I finally tried ASP.NET MVC Preview 4 today at a high level..... still need to dive deep in !

Here are few things worth noting


  • ComponentController is removed and now you can use Html.RenderAction<> instead of Html.RenderComponent<> e.g. Html.RenderAction(x=>x.BlogList())
  • Html.SubmitButton - is removed and went into a different namespace... Microsoft.Web.Mvc
  • MembershipProvider is in built in this preview BUT only the FormsAuthentication is taken care of (and not the FormsAuthenticationAdministration class) so you get automatic creation of all user account classes (login, changepassword, register etc) but the admin functionality is still missing....hoopefully in the next preview we get those !

Here are few links to articles for ASP.NET MVC Preview 4:

***BTW TROY GOODE is releasing a new version of MVC Membership toolkit for Preview 4 tomorrow and next week with some enhancements below:

  • 1st Release tomorrow will contain removal of the front-end controller & views (which are now part of the default MVC project template) as well as switching over to the new [Authorize] and [HandleError] attributes.
  • The 2nd release next week will focus on improving the administrative interface for managing users using the new MS Ajax goodness.

Entity Framework Beta 3 With .NET 3.5 SP1

If anyone has run into issues with the new 3.5 SP1 and ADO.NET EF they know what I'm talking about. The other day I upgraded my system with .NET 3.5 SP1 to run Dynamic Data samples. What I get in return is multiple errors while editing or adding tables to my EDMX file which did not make any sense (one of those wierd non descriptive errors). Finally after lot of "struggle" I could trace the issue.... I had to uninstall my Entity Framework Beta 3 and .NET 3.5 SP1 and then reinstall .NET 3.5 SP1 onto my machine.... not forgetting to restart my machine couple of times.

Bottom Line: Unistall any version of ADO.NET Entity Framework on your box and then install .NET 3.5 SP1 or else you'll see all thos erros I talked earlier


This post will help anyone with similar issues and avoid having them spend half a day on investigating the issue with no clue.

*****BTW Dynamic Data for MVC Preview 4 has been release today and I am testing at this moment... keep checking and I'll keep everyone posted of the new release.

Wednesday, July 16, 2008

Here ya go ---ASP.NET MVC Preview 4 -- CodePlex

So its finally here.... CodePlex MVC Preview 4 for ASP.NET

I blogged earlier about some new features for MVC release.

Its been released few days earlier than the ASP.NET Team release. I am going to use and test this new preview and blog about the new features and changes:

Includes: Membership Provider, AccountController, Error Handling, Output Cache.