0

In our testing, it seems we've found an issue where Document/Record Libraries in SharePoint 2013 refuse to work properly with a custom field control.

We created a very simple custom field control, where the code behind is only the necessary constructors and one overload. We created a custom content type that inherits from Folder, and associate our site column/field type to the new content type. We then add that content type to a Document Library, and when we attempt to create the new 'folder' (our content type), it has only two columns: Name and My Custom Field. When we try to save it, Name blanks out and doesn't give us any information, validation error or exception. It just won't allow us to save.

Has anyone seen this behavior in SharePoint 2013? It works just fine in 2010 and 2013/2010 compatibility mode.

fldtypes_KDDCustomFieldType.xml

<FieldTypes>
  <FieldType>
    <Field Name="TypeName">KDDCustomFieldType</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">KDDCustomFieldType</Field>
    <Field Name="TypeShortDescription">A base type for fields containing XML data</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="ShowInListCreate">TRUE</Field>
    <Field Name="ShowInSurveyCreate">TRUE</Field>
    <Field Name="ShowInDocumentLibraryCreate">TRUE</Field>
    <Field Name="ShowInColumnTemplateCreate">TRUE</Field>
    <Field Name="FieldTypeClass">SharePointProject2.KDDCustomFieldType, SharePointProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=619a5463ce63f5d4</Field>
  </FieldType>
</FieldTypes>

KDDCustomFieldType.cs

public class KDDCustomFieldType : SPFieldText
{

    public KDDCustomFieldType(SPFieldCollection fields, string fieldName)
        : base(fields, fieldName)
    { }

    public KDDCustomFieldType(SPFieldCollection fields, string typeName, string displayName)
        : base(fields, typeName, displayName)
    { }

    public override BaseFieldControl FieldRenderingControl
    {
        get
        {
            BaseFieldControl fieldControl = new KDDCustomFieldTypeControl();
            fieldControl.FieldName = InternalName;
            return fieldControl;
        }
    }
}

public class KDDCustomFieldTypeControl : TextField
{
    public KDDCustomFieldTypeControl()
    {

    }
}

KDDCustomSiteColumn\Elements.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  <Field ID="{43e5e2f6-0912-4e37-9fd2-15a8f1bed5c1}"
       Name="KDDSiteColumn"
       DisplayName="KDD Site Column"
       StaticName="KDDSiteColumn"
       Type="KDDCustomFieldType"
       Required="FALSE"
       Group="Custom Site Columns" >
  </Field>
</Elements>

KDDFolderContentType\Elements.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Folder (0x0120) -->
  <ContentType ID="0x01200009E648A45D01452FABCDD2B0599BC8E2" Name="KDDFolderContentType" Group="Custom Content Types" Description="My Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{43e5e2f6-0912-4e37-9fd2-15a8f1bed5c1}" DisplayName="KDD Site Column" Required="FALSE" Name="KDDSiteColumn" />
    </FieldRefs>
  </ContentType>
</Elements>

Thanks in advance, Kyle

  • Did you find a solution for this issue, as i have the same issue and looking for an answer. – user21522 Dec 19 '13 at 12:54
2

In Sharepoint 2013, you create custom field type is by using JSLink as this concept has been newly introduced.

so instead of overriding BaseFieldControl, Override the JSLink property as shown below:

public override string JSLink
    {
        get
        {
            return "YourCustomJSFile";
        }
        set
        {
            base.JSLink = "YourCustomJSFile";
        }
    }

This custom JS file should contain the field rendering logic.

Refer below links for how to create custom field types using jslink

http://spdevlab.com/2013/06/09/custom-field-type-for-sharepoint-2013-visa-card-field-sample/

http://www.lestersconyers.com/custom-field-rendering-with-jslink/

http://www.learningsharepoint.com/2013/04/13/sharepoint-2013-js-link-tutorial/?goback=%2Egde_3839320_member_231939494

0

It may also be recommended to avoid introducing any new field types. Just use out of the box one and change look & feel & behavior with JSLink property.

0

i faced this issue and found the workaround

  • open the form for your custom content type
  • edit page
  • edit webpart
  • in the section miscellaneous set the CSR Render Mode to "Server Render"
  • Apply changes

printscreen

and now you should be able to save

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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