Skip to main content

Posts

SharePoint Edit Form - Check Unique Values in Fields

You will always come across customers with interesting requirements and we had one. The SharePoint site has a document library in which content was organized within Document sets (i.e documents were created and stored within document sets). One particular field (say Field 1) was shared between the document set and the document to cascade the values. The requirement was to have unique values in Field 1 within the library. We could not set "Enforce unique values" for Field 1 since it will not allow us to share the value of the field with the documents inside the document set. JQuery as usual was the savior. We had to leverage the SPServices functions to achieve what was expected. SPService has a function SPRequireUnique which did not work well for us since it was large document library with more than hunderd thousand documents. SharePoint has a PreSave function which is invoked prior to saving the item in the Database. This is very handy when you need to perform custom v
Recent posts

JQuery Quick Menu

Building a menu using JQuery is too simple.  Here the script reads from an XML file to build the menu items. Sample xml <Root>   <Menu Text="Home" URL="" ToolTip="Home" ID="m1" >     <SubMenu Text="About us" URL="" ToolTip="About us"></SubMenu>     <SubMenu Text="Contact us" URL="" ToolTip="About us"></SubMenu>     <SubMenu Text="Careers" URL="" ToolTip="About us"></SubMenu>   </Menu>   <Menu Text="Company" URL="" ToolTip="Home" ID="m2" >     <SubMenu Text="Clients" URL="" ToolTip="About us"></SubMenu>     <SubMenu Text="Management" URL="" ToolTip="About us"></SubMenu>   </Menu> </Root> JQuery $(document).ready(function () {             $.ajax({            

Enable Session State in SharePoint 2010

You would have noticed that after installing SharePoint 2010 and deploying your custom solutions, code which is dependent on Session variables would not work as expected. That is because the Session state is not enabled by default. You just need to run this cmdlet in Powershell and boom Session starts working. Enable-SPSessionStateService –DefaultProvision A new service Application by name "SharePoint Server ASP.NET Session State Service" should be available. The web.config will have this additional entry under configuration/system.webserver/modules Also dont forget to change the attribute "enableSessionState" to true in the page Element.

SPWebConfigModification

SharePoint offers the SPWebConfigModification class to update web.config entries. We can have a Feature receiver at the Web Application scope and on activation propgate the web config changes to all the WFE servers .. This is good right? But the caveat is that the class is not so flexible. It does not allow us to reorder the entries within a section which is really important in case of custom Http modules ad handlers. Hope MS takes care of this in the next update ..Hers is a sample code to add the connection strings section and update the enableSessionstate attribute. SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent; SPWebConfigModification wcupdate1 = new SPWebConfigModification(); wcupdate1.Owner = "Any Name"; wcupdate1.Name = "enableSessionState"; wcupdate1.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; wcupdate1.Path = "configuration/system.web/pages"; wcupdate1.Value = "true"; //

Powershell Power

Recently we discovered an issue where the Site Deleting event receiver was being triggered when we migrated teamsites from one content DB to another. This was something we never anticipated since we were just moving sites and not deleting them. We figured out that the event receiver was being triggered since the custom teamsite data was being deleted from the source content DB. So we decided to come up with a powershell script to restore the list and DB table.In my opinion Powershell scripting just rocks. I just want to share some snippets from the code that updates a SharePoint list and DB. $web = $site.RootWeb $web.AllowUnsafeUpdates = $TRUE $teamsitemasterlist = $web.GetList($TeamsiteListName) $newlistitem = $teamsitemasterlist.Items.Add() $newlistitem["Title"] = $teamsiteTitle $newlistitem["Description"] = $teamsiteDescription $newlistitem["Provisioning Status"] = "Provisioned" $newlistitem.Update() $sqlconnection = new-object Sys

SharePoint Blog Posts

Today we just resolved a pending issue. Our custom WP which aggregates the latest posts from all the blog sites in our site collection threw up a SQL Error " All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists ". We were unable to replicate the issue in our test servers. Even the OOTB CQWP could not surface the blog posts. Pretty strange uh.The fix was pretty simple. We had two blog sites Site A and Site B. Both the sites had only the default site columns provisioned. When you try to edit the settings for any column of type "Person or Group" in any SharePoint List, you see an additional dropdown list "Show field". The columns in both the sites need to have the same value in "Show field" when you are querying items from two different lists (SPSiteDataQuery or CrossListInfoQuery)  For example, a column called "Created By" exists for all the Blog posts in Site

Welcome 2010

2010 has just started but is already turning out to be eventful. Jan 1st welcomed us with the Antivirus live spyware attacking my personal laptop. Spybot finally helped me clear the mess. The Stock Market does not seem to be fair with me as all my stocks just hit rock bottom. My kid has started walking like she has never before (actually she is 13 months old and just started walking a few days back). Dad and Mom have just flown to the Thailand with their army of friends. Phuket according to them is like some place in heaven :) . Authors and Producers are fighting over who should be given the credit for a movie based on a novel. I dont think this has ever happened in any movie adapted from a novel. People in the same state have different opinions on the formation of another state. Politicians surreptiously playing a game of supremacy. Medals being snatched from cops :) India losing their first one dayer after having an extremely dominant year Cleveland Cavs ending their 7 game winning s