Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
Let us see your content type defintion –  James Love Nov 27 '12 at 19:32
add comment

1 Answer

up vote 1 down vote accepted

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()
             }   
         }                                  

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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