2

I'am deploying some site columns, content types and lists to my site via CAML definition. This works as expected. However, I faced problems with re-using site columns that reference my lists.

My site column definition looks like this:

<Field Name="MyProduct" DisplayName="My Product" 
       ID="{c7118bfc-7848-499a-9f7c-5700576be23f}" Type="Lookup" Group="My Group" 
       List="Lists/MyProducts" ShowField="Title" />

This field is contained in a CAML content type definition and in a CAML list definition(schema.xml). I have no problems with this list, everything works as expected. But whenever I try to add the field to another list (in SharePoint via Browser as well as programmatically in a command line tool) I get an ArgumentException with the corresponding nativehr but without further details, not even in the log files.

For some other problems it is often suggested to add the Overwrite="TRUE" attribute to the field definition (e.g. here, here,...). This solves my problem, too.

But the documentation of the attribute on MSDN does not give me an explanation why this solution works:

Specifies whether the field definition for a new field that is activated on a site (SPWeb) overwrites the field definition for an existing field, in cases where the new field has the same field ID as the existing field. True if the new field overwrites the existing field with the same field ID; otherwise false. The default is false.

The problem also occurrs when I don't use the lookups in my custom lists. And I also tried it with complete removal of all my lists, content types and site columns - same result.

Could someone please explain me what makes the difference here between setting the Overwrite attribute or not? Does it have any side effects to set the attribute value to TRUE?

2
  • Did you define the column group "My Group" elsewhere in your list definition? That looks like the only thing in there which could be throwing an error on an existing list or list type, as "My Group" is not one of the default column groups. Commented Jun 4, 2013 at 22:19
  • I did not define any column group. I always thought that adding a "Group" attribute to a site column would be sufficient?!
    – Stephan
    Commented Jun 5, 2013 at 9:14

2 Answers 2

2
+50

Site columns in content types is a great way to group several columns in a meaningful (and reusable) way, and then attach the content types to the list. Having said that, you can define all the site columns in one file (Say SiteColumns.xml) and user FieldRef to reference them in your content types (say ContentTypes.xml). You can always ensure to activate Content Types/Site-columns feature first, before using them in your custom lists.

I really don't think so if the Overwrite attribute has to play any role, except updating the field definition. The underlying error is possibly occurring because some of your column may not be provisioning correctly.

5
  • That's exactly what I'm doing: I define the site column in one XML file and I use it in a content type, that is defined in another XML file. (And I use it in deployed list as well (Schema.xml), which works fine). But I cannot add the column to other lists even though the feature is activated
    – Stephan
    Commented Jun 5, 2013 at 9:02
  • Can you add the columns via SharePoint interface? Commented Jun 5, 2013 at 10:53
  • No, I get an error page with the mentioned ArgumentException.
    – Stephan
    Commented Jun 5, 2013 at 14:08
  • Why your field column is not using SourceID attribute? SourceId is supposed to be set by the framework to the feature that created the field. SourceId is supposed to help you work back to the feature that created the fields SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"/>. Check this link for more details: sharepointchick.com/archive/2009/06/30/… Commented Jun 5, 2013 at 14:42
  • If the SourceID is supposed to be set by the framework, why should I add it to my field definition?
    – Stephan
    Commented Jun 10, 2013 at 12:45
0

If the field "My Products" exist in the site with the same ID so you should add just a reference to this field. I mean you should use <FieldRef >. Otherwise try to change the ID and the Name of your new field.

1
  • The field does not exist and there is no field with the same ID.
    – Stephan
    Commented Jun 3, 2013 at 9:21

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.