1

I have the following code:

list.ContentTypes.Add(contentType);

It works on my dev environment, but on test fails with the following error:

A duplicate field name "[GUID]" was found.

I've had several attempts at trying to find this field that it complains about via powershell (really simple script to get the web and then attempt to get the field by id) and it can't find it anywhere.

Can anybody please help me identify a possible cause for this duplicate field when I can't even find it?

Please note, I've tried this on different webs and the GUID is exactly the same, so it's a site column/field that exists and the site collection level I'm assuming (I've even ran the powershell script against the site's root web).

EDIT: I've also searched my solution for this guid - couldn't find it.

1
  • Let us see your content type defintion
    – James Love
    Nov 27, 2012 at 19:32

1 Answer 1

1

Try the SharePoint Manager to find the duplicated field ID in the existing Site collection or on the relevent lists. Hopefully you will found it.

I wonder if it is possible for you to change the GUID of the field, causing the problem?

Update:

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$site = Get-SPSite "http://your.site.com"
foreach($web in $site.AllWebs)
{ 
    #iterates through all the Lists        
    for ($i = 0; $i -lt $web.Lists.Count; $i++) 
    { 
      $list = $web.Lists[$i];                               
      $MyListContentTypes = $list.ContentTypes                                                          
      if ($MyListContentTypes -ne $null)
      {

         $cts = $list.ContentTypes
         foreach($ct in $cts)
         {
              if($ct)                                                            
              {


                $ct.FieldLinks.Delete($ct.Fields["GUID"])                                  
                $ct.Update()
             }   
         }                                  

       }
    }     
  }
9
  • Thanks a LOT for your reply Falak. I can't appear to find the id in any of the content types? Nov 30, 2012 at 10:53
  • Are you sure the field is not hidden? Can you paste the ContentTypes provisioning code? Nov 30, 2012 at 14:49
  • Have you changed the GUID of the field causing the problem? Dec 1, 2012 at 17:20
  • I can't change the GUID of the field because I don't know what field it is. Dec 3, 2012 at 10:20
  • 1
    Great to know that :). Mark it as answer if it has helped you :) Dec 4, 2012 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.