1

I've created a list that contains a cumstom field. The custom field inherits from SPFieldUser. After I created a new ListItem (webfrontend) and have a look on the elements details the field is empty.

Webfronted NewItemForm Webfronted NewItemForm Webfronted ItemDetailsForm Webfronted ItemDetailsForm Webfronted EditItemForm Webfronted EditItemForm

My Code:

public class Vertreter_FieldType:SPFieldUser
    {
     public Vertreter_FieldType(SPFieldCollection fields, string fieldName)
           : base(fields, fieldName)
       {

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

        public override object GetFieldValue(string value)
        {
            return base.GetFieldValue(value);
        }

        public override string DefaultValue
        {
            get
            {
                return base.DefaultValue;
            }
            set
            {
                base.DefaultValue = value;
            }
        }
    }

XML-fldtypes:

<FieldTypes>
  <FieldType>
    <Field Name="TypeName">Vertreter_FieldType</Field>
    <Field Name="ParentType">User</Field>
    <Field Name="TypeDisplayName">Vertreter</Field>
    <Field Name="TypeShortDescription">Auswahl Vertreter</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">CustomFieldTypes.Vertreter_FieldType, $SharePoint.Project.AssemblyFullName$</Field>
  </FieldType>
</FieldTypes>

My Contenttype the List bases on:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
...
<Field ID="{2C338272-3BC8-45bc-B33E-5FBD1223F398}"
         DisplayName="Administrator" Name="Administrator" 
         Type="Admin_FieldType" Required="TRUE"
         UnlimitedLengthInDocumentLibrary="FALSE"
     />
  <Field ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}"
         DisplayName="Vertreter" Name="Vertreter"
         Type="Vertreter_FieldType" Required="TRUE"
         UnlimitedLengthInDocumentLibrary="FALSE"
         >
  </Field>
...
  <FieldRefs>

...
     <FieldRef ID="{2C338272-3BC8-45bc-B33E-5FBD1223F398}" Name="Administrator" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
     <FieldRef ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}" Name="Vertreter" Required="TRUE" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
 ...

    </FieldRefs>
  </ContentType>
</Elements>

Thanks for your help!

6
  • If you edit the element is the content then present? Apr 26, 2012 at 6:50
  • @PerJakobsen no the fields are empty too.
    – MOI
    Apr 26, 2012 at 6:54
  • did you use List="UserInfo" attribute in list fields declaration?
    – Alexander
    Apr 26, 2012 at 7:37
  • @Alexander I've added the Fielddeclaration. The declaration ist placed in a seperate contenttype.
    – MOI
    Apr 26, 2012 at 7:47
  • 1
    try to use <Field ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}" DisplayName="Vertreter" Name="Vertreter" Type="Vertreter_FieldType" Required="TRUE" UnlimitedLengthInDocumentLibrary="FALSE" List="UserInfo">
    – Alexander
    Apr 26, 2012 at 7:52

1 Answer 1

2

try to use this declaration

<Field ID="{585CE72A-72D7-4ecc-8324-484BA1E483F1}" DisplayName="Vertreter" Name="Vertreter" Type="Vertreter_FieldType" Required="TRUE" UnlimitedLengthInDocumentLibrary="FALSE" List="UserInfo">

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.