Hide the Title field from a SharePoint list (both from its default view and in the New and Edit dialogs)

Thursday, 10 May 2012 14:41 by Chad
SPList list = web.Lists[listName];

var title = list.Fields["Title"];

title.Hidden = true;
title.ShowInEditForm = false;
title.ShowInDisplayForm = false;
title.ShowInNewForm = false;

title.Update();
list.Update();

owssvr.dll sometimes returns nothing

Monday, 7 May 2012 17:50 by Chad

Sometimes when using the old owssvr.dll to get list items in SharePoint, it will simply return nothing, and I mean nothing! FireBug shows no response body at all. And nothing in the ULS. Thanks SharePoint, your being about as helpful as you usually are. Yell

Adding &Query=* to the URL seems to fix this. Not sure why. And it is case sensitive.

Instantly improving VC++ project build times

Saturday, 5 May 2012 20:05 by Chad

Everyone has multicore machines these days, so make sure you turn on the 'Build with Multiple Processes' flag on your VC++ projects. It will spawn mutliple instances of the compiler targeting each core and each will build separate files, improving your build times dramatically.

Compiling a 10,000 line C++/CLI project went from 30s to 14s build time.

Simply browse to the projects property dialog, then C/C++, General and turn on the Multi-processor Compilation property.

 

An almost blank page gives you a 'List does not exist' exception in SharePoint

Saturday, 5 May 2012 14:47 by Chad

Situation

You've got a .aspx file that only contains the following, yet it still gives you a meanless "List does not exist" exception.

<%@ Reference VirtualPath="~masterurl/custom.master" %>
<%@ Page language="C#"   Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

 

One solution

You'll notice the page is inheriting from Microsoft.SharePoint.Publishing.PublishingLayoutPage class. This class will be trying to access a list which, if the publishing feature is not enabled, will not exist.
Either, enable the publishing feature so the list will exist, or, change the page to inherit from Microsoft.SharePoint.WebPartPages.WebPartPage in the Microsoft.SharePoint assembly instead, which does not have the list dependency.

SharePoint owssvr.dll errors in Cannot complete this action. Please try again.

Thursday, 26 April 2012 16:52 by Chad

Error
When using the old list URL/web service (e.g. http://sharepoint/_vti_bin/owssvr.dll?Cmd=Display&List=9133B60C-77C0-4B33-989D-49DC27794101) you receive "Cannot complete this action.  Please try again."

One solution
Add &XMLDATA=TRUE to the URL

You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.

Monday, 9 April 2012 16:48 by Chad

Error

You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.

One Possible fix

Change the project build/output from Multithreaded Debug DLL to Multithreaded DLL

Content type dependency inside a single SharePoint feature

Monday, 26 March 2012 16:20 by Chad

I defined two content types; A and B, B relied on A. and both were in the single feature.
However when it came time to deploy I received an error: Error occurred in deployment step 'Activate Features': The parent content type specified by content type identifier 0x010029043F0D68EC4DF1BC85141AFF451661 does not exist.

I looked in the Manifest.xml file that Visual Studio generates inside the wsp/cab file and noticed the two content type Elements.xml files were defined the wrong way around:

  • B/Elements.xml
  • A/Elements.xml

A work around to this is to simply force the order of certain Elements.xml file in the feature (i.e. put the 'root' content type files first).

<ElementManifests>
 
<ElementManifest Location="A\Elements.xml" />
</ElementManifests>

Open the feature, go to Manifest, open Edit Options and enter the file you need to be specified first in the list of Elements.xml files. This emits the following XML into the manifest file:

<ElementManifests>
 
<ElementManifest Location="A\Elements.xml" />
 
<ElementManifest Location="B\Elements.xml" />
</ElementManifests>

Error when adding a field to a View of a SharePoint list via the Schema.xml file

Monday, 26 March 2012 12:58 by Chad
Errors
ULS exception
Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.WebPartPages.XsltListViewWebPart.AddInFieldSchema(XmlNodeList fieldRefNodes, SPList list) at Microsoft.SharePoint.WebPartPages.XsltListViewWebPart.ModifyXsltArgumentList(ArgumentClassWrapper argList) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)
Friendly UI error
Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.

 

A possible solution
Double check your FieldRef element is complete in your Schema.xml file, under: /List/MetaData/Views/View/ViewFields
<FieldRef
ID="{5DEB5C3A-A0F9-43AF-B150-ABC70D3C748F}"
Name="ContactName"
DisplayName="Contact Name"/>

SharePoint list fields are not required even when setup as such

Friday, 23 March 2012 13:54 by Chad
Field definition
<Field ID="{CCD512A7-AC8D-4613-B127-76D7B4612111}"
	Name="About the team"
	DisplayName="About the Team"
	Group="Group A"
	Type="Note"
	Required="true" />

 

Solution
<Field ...
	Required="TRUE" />

Use all caps for TRUE and FALSE.

Hiding the Title field declaratively

Friday, 23 March 2012 12:05 by Chad

If you make a new content type for SharePoint 2010 using the Visual Studio 2010 tools you get lots of magical elements.xml files and a Schema.xml file.

Once you've setup your ContentType and FieldRef's you'll notice your fields are not displaying in your list, this is simply because they're not in the default View yet. In the Schema.xml file, simply add FieldRef elements underneith the ViewFields element (on about line 40). In there you'll notice two default fields in the view; Attachments and LinkTitle, simply remove or comment these out to hide them from the view.

Schema.xml:

<ViewFields>
          <!--<FieldRef Name="Attachments"></FieldRef>-->
          <!--<FieldRef Name="LinkTitle"></FieldRef>-->
 
	<FieldRef Name="TeamId" />
	<FieldRef Name="TeamName" />
	<FieldRef Name="TeamLead" />
	<FieldRef Name="TeamParentTeam" />
</ViewFields>