Showing posts with label fields. Show all posts
Showing posts with label fields. Show all posts

Wednesday, 3 November 2010

Error occurred in deployment step 'Activate Feature': A duplicate field name "xx" was found.

Problem: A site column/ field occurs more than once.  I.e. there is a duplicate field name.
Initial Hypothesis:  If you are deploying site columns declaritively (CAML), you will have 2 site columns with the same name and type.  This commonly happens with "Email" so be more specific or reuse the exisitng site column. 
Resolution:  Ensure thre duplicate field name is unique or reuse an exisitng suitable site column.

If you have check that you don't have the issue above and you are deploying using Visual Studio 2010 use the following advice.  This occurs after you have renamed or deleted the site columns as explained above.

Problem: Deploying site columns using VS results in the error "Error occurred in the deployment step 'Activate Features': A duplicate field name "Email" was found. 
Initial Hypothesis: Ensure you don't have duplicate fields as show in the above problem solver.  Activate the feature using ststadm, it will now work.  The problem is that Visual Studio on it's 1st build and deployment caches SharePoint information, this was done by MS to speed up subsequent deployments of code.  However, the cached VS SP info is now wrong so restart VS 2010 and deploy again.
Resolution:
  1. Retract the solution that holds the failing feature;
  2. Close and reopen the Visual Studio Project; and
  3. Deploy the feature using VS 2010. 

Thursday, 23 September 2010

Creating Site Columns / fields declaratively

Problem: Adding site columns decoratively has nuances.  This post adds information for getting fields/site columns correct when building them declarative using a feature to deploy to a Site Collection.

Resolution: You can use the following reverse engineering technique on the list.  This will show you the xml/CAML to create lists.  This works in MOSS & SP2010.  I used the list reverse engineering technique to figure out how to create a Lookup site columns with multiple values. 

Steps to Reverse engineering a SharePoint List:
1.> Create a list, content type and site column for the lookup (or field you want) using the SharePoint's UI
2.Then retrieve the list using a formatted url to see the native CAML used to create the site column.  http://url/_vti_bin/owssvr.dll?Cmd=ExportList&List=listguid
This approach saved me a lot of time today.

Tips:
CAML attributes required for each field element are: ID, Name, DisplayName, Group, and Type.
MSDN field element attributes
Attributes explained
Type="Note" will create a site column in the UI showing "Multiple line of text".  Attribute to get full html imput capabilities are RichText="True" (default is false)  & RichTextMode="FullHtml".
Type="Choice" can have a default value selected as shown below:
Built-in Site Column Append-only Comment can be referenced in a content type to provide comments that are appended and basic html is available.
Lookup columns work in SP2010 without having to create an event receiver to setup the lookup relationship using the list guid as is the case in MOSS.  Multiple lookups are possible also simple set the field attributes Type="Lookup" & Mult="TRUE".

Tip: Updated 18 Oct 2010 - CKSDev has the functionality to import Site Columns, this is useful in that you may of created the SiteColumns via the UI on a prototype site and you can not easily get the xml to create the site columns/fields declaritively. http://blog.mastykarz.nl/cksdev-support-importing-site-columns/