Friday, January 16, 2015

What to do if "Save library as template" link is missing in your SharePoint site

If you don't see the "Save library as template" link in the document library settings page of your SharePoint site, just look at the url of the Library Settings page - you will see there is a "listedit.aspx" present in the url. Change that with "savetmpl.aspx" and voila!

Tuesday, September 23, 2014

Resolving the error "You must specify a value for this required field" while trying to save and close a SharePoint webPart page

If you are working in a SharePoint project and at the time of working in a SharePoint page, starts getting an error stating "You must specify a value for this required field" at the time of saving the changes done to the page though you are sure you have all the webPart properties are set with right values, then check one more thing - are you using custom master page?

Many times when we design custom master page, we comment out the code block inside the master page which is responsible of showing the Navigation Breadcrumb inside the ribbon. That block is present under the div tag with id 's4-workspace' and with asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea".
So make sure this ContentPlaceHolder is not commented out. If you don't want it to appear in your master page, you can use the Style="display:none" function as shown below. Save it and go back to the page where you got the error and try to save it. You will see the page will be saved without throwing any error!

How to make SharePoint 2010 site logo to take you to the Root Site Collection Home Page

Many time we have got requests from end users and site owners to change the out of box site logo's behavior so that when they select it, it should take them to the home page of the root site collection. And this is a very fair request and the common behavior of most of the websites present in the internet. The default behavior of the SharePoint site logo is to take you to home page of the current site from where you have selected the logo. To change it open the Master Page of your site in Edit mode in SharePoint Designer. 
Search for the div id 's4-workspace'. Little inside that div you are going to find a Table Column with class 's4-titlelogo' and "SharePoint:SPLinkButton runat="server" NavigateUrl="~site/"... inside that column.
Just change the NavigateUrl property value to "~siteCollection/" and save and publish the master page.
Now go back to your site, navigate to any sub-site and from inside that sub-site, click on the site logo and you will notice it will take you to the home page of the root site collection. Thats it!

Thursday, September 4, 2014

How to resolve "The security validation for this page is invalid" error in SharePoint 2010

How to resolve "The security validation for this page is invalid" error in SharePoint 2010

It may possible many time when you are running custom code in SharePoint's context you are getting the following error:

Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> System.Runtime.InteropServices.COMException: 

This error can be thrown for different reason but the prominent one that I noticed is when some list/ library edit/ update operation happens in the code and SharePoint tries to protect unsafe updates to its list/ libraries.
To resolve the same error in such cases you need to put your code between the following code stub:

Now rebuild the solution and deploy and test again!

How to add ECB Menu Item for specific SharePoint List or Library

How to add ECB Menu Item for specific SharePoint List or Library

To add ECB Menu Item for specific SharePoint List or Library, first you need to know the Registration ID for that list. To get that, go to the desired List's Settings page and then select Advanced Settings. In that page, enable Management of Content Types and select OK. Now in the List settings page, go to the Content Type Section and select the Content Type listed there.

So in my case, when I selected Document content type, it took me to the next page and in the URL of the next page you have the 'ctype' listed at the end of the url:

Copy that CType as that is going to act as your Registration ID.
Next go to your Visual Studio solution and open Element.xml file. Change the RegistrationType's value to 'ContentType' and place the copied CType value to the 'RegistrationId's value field:

Now just save the file, and deploy the solution from visual studio if working in your development environment or else install and activate the feature to notice the custom ECB Menu only appearing in the specific list :)

How to deploy a WSP to a specific Web Application

How to deploy a WSP to a specific Web Application

Many time there will be requirement to deploy a custom solution to a specific Web Application. But at the time of deployment Power Shell starts throwing the following error:

Install-SPSolution : This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application. 
At D:\XXX\YYY\DeployWSP.ps1:2 char:19 + Install-SPSolution <<<<  -Identity CustomSPSolution.wsp -webApplication "http://testSPSite" -GACDeployment + CategoryInfo : InvalidData: (Microsoft.Share...InstallSolution: SPCmdletInstallSolution) [Install-SPSolution], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletInstallSolution

From the error message it is clear that SharePoint is looking for some resources specific to the web Application and could not find any. In many cases it is possible that your custom solution don't need any web application specific resources and in those cases we need to fool SharePoint thinking that the WSP has some Web Application specific resources. To do that open you Visual Studio solution and then double click on the Package folder present in the Solution Explorer. Once it is opened, select the Manifest tab and expand the 'Edit Option' present at the bottom of the page. In general Manifest Template going to have following text:

Inside the Solution node paste the following code stub:
Change highlighted sections as described and you will be good to deploy your WSP to a specific web application from the Power Shell command prompt.

Tuesday, July 22, 2014

Showing Picture with hyperlink to open link in a new window

Showing Picture with hyperlink to open link in a new window

There are many ways to achieve this functionality –

Adding a Content Editor WebPart and Pasting the following code as mentioned by David Lozzi in his blog:


Another way is to create a Site Column of type “Image with formatting and constraints for publishing” in the root site collection. Once you have created this site column, you can add it to any existing list/ library and then at the time of adding an item you can just use this property to add a picture with hyperlink and if you set “Open in a new window” property for the newly added site column, the link will open into a new window.

Thursday, June 19, 2014

How to download all the photos from a dead old giant named ORKUT!!!

Copy - Paste from the following url:

In order to download your Orkut information, you must be the owner of the account. Some Orkut information can be downloaded using Google Takeout in a single ZIP file containing HTML files and JPEG photos.
You can download these items from Orkut:
  • Your profile
  • Scraps received
  • Testimonials received
  • Activities
  • Your photos
Note that you can only export the testimonials and scraps you have received and their comments.
To download your Orkut information:
  1. Go to the Google Takeout page.
  2. Click Choose services and then select Orkut.
  3. Click Create archive.
  4. Wait for the archive to be ready. It may take some time. Optionally, you can be warned by email when it's ready.
  5. When it's ready, click download.
There's no limit on how many times your Orkut information can be downloaded.

Status Indicator webPart not showing status icon

Today I created a SharePoint list (say XYZ) and then a Status List. Then in the Status list I added the SharePoint list XYZ by selecting New > SharePoint List based status indicator. It was working as expected.
Next I went to the Home page of my site and as per the requirement tried to show the current status by editing the page and then adding the Status List WebPart there. But as soon as I finished adding the Status List as a webPart, I noticed the Status Indicator was not showing up. I created new views, changed different settings but of no use. Soon I realized there must be a different way to show the status in the webpart. And that way is to use Status List webPart or Indicator Details webPart from under the Business Data webPart category. Once you add either of the above into the page, it is going to tell you to 'Open the tool pane' to configure it. In the tool pane select your Indicator List i.e., your status list and select Apply > OK and you are done! Save the page, check it in if necessary and now you will see the status icon showing up in your desired page.


Wednesday, June 11, 2014

ItemUpdating event receiver throwing error - 0x81020015The file has been modified by ...

Few days back I tried to create an event receiver on a SharePoint Library which is going to fire whenever somebody adds a new record. At the time of adding the record the event receiver was supposed to add the logged in users name into a custom column. But to my great amusement it started throwing the following error:

0x81020015The file XXX has been modified by...

Unfortunately I was not able to fix it and after doing a lot of RnD was not able to find a conclusive solution.
It looks like a read/write lock problem and I was not interested in sending a thread to sleep. So I changed my logic a little bit and started implementing the same logic in Item_Updated event. So if you face the same error, then if Googling doesn't help you much, then I will suggest to tweak the logic and use Item_Updated event! Sorry!