1

I've created a list programmatically with two site columns (title, name (peoplepicker))

enter image description here

The list show both site columns but when I try to create a new item only the title will show, "name" (people picker) are missing. It's not a content type!

enter image description here

Code for creating the fields:

<Fields>
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="$Resources:core,Title;" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" MaxLength="255" />
  <Field ID="{12B2742C-2A44-4792-935C-5504B1CC2198}" Type="User" DisplayName="Name" List="UserInfo" Required="FALSE" EnforceUniqueValues="FALSE" UserSelectionScope="0" ShowField="ImnName" UserSelectionMode="PeopleOnly" StaticName="Name1" Name="Name1" />
</Fields>

views example:

   <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="LinkTitleNoMenu"></FieldRef>
      <FieldRef Name="Name1"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
    </ParameterBindings>
  </View>

EventReciever:

            if (importantRolesList != null)
            {

                SPList oList = web.Lists[ImportantRolesListName];
                SPListItem oSPListItem = oList.Items.Add();
                oSPListItem["Title"] = "testitem";
                oSPListItem.Update();


                var importantrolesWP = new XsltListViewWebPart
                {
                    Title = ImportantRolesListName,
                    ChromeType = PartChromeType.TitleAndBorder,
                    ListName = importantRolesList.ID.ToString("B").ToUpper(),
                    ViewGuid = importantRolesList.DefaultView.ID.ToString("B").ToUpper()
                };



                webPartManager.AddWebPart(importantrolesWP, RightZoneId, 3);
            }
  • Please provide the code which is used for the list creation. – Alexander Jul 29 '14 at 11:46
  • You need to add the field reference to the content type of the list. – Alexander Jul 29 '14 at 12:01
  • It's not a contenttype – Plexus81 Jul 29 '14 at 12:18
2

In my listdefinition (schema.xml) I had some CT's. Like

<ContentTypes>
  <ContentTypeRef ID="0x01">
    <Folder TargetName="Item" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
</ContentTypes>

This was added when I used the "wizzard" in visual studio, where I added custom list.

just remove all those if you don't have an CT, like so

<ContentTypes>
</ContentTypes>

This solved my problem, all site columns does now show in newform

IF you have added the site column to a CT, remember to put it inside

  • This should be documented by Microsoft somewhere but its really hard to find it. But it worked for me too – love thakker Apr 13 '17 at 12:02
1

Try adding the attribute ShowInNewForm = "true" to your Field-Definition (Field ID=....)

Reference : http://jasear.wordpress.com/2011/12/28/sharepoint-2010-list-fields-not-showing-up-in-edit-display-or-new-forms/

  • Doesn't work. PeoplePicker may cause the problem. – Plexus81 Jul 29 '14 at 12:17
  • is there a reason why you can't do it via list settings? – Gwny Jul 29 '14 at 13:02
1

You have to add your field to the content type. See this post for more details. It describes your issue.

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.