1

I would like to use my own custom ListItem template. I also would like to overule the ListFieldIterator method to use some logica to include or exclude some fields dependance on user/usergroups:

http://msdn.microsoft.com/en-us/library/aa543922%28v=office.12%29.aspx http://blog.octavie.nl/index.php/2011/09/04/customizing-listitem-forms-using-renderingtemplates/

I have copied the default ListItem template and add it to my custom content template. All in custom code.

I have deploy my whole solutution and did some test. I go to my custom ListItem and created an item. It see the default listItem template. So something go's wrong.

Can someone give me some tips to check where the problem is?

In my custom code I create my custom list and custom content type. In my content type I have reference to my custom template:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Item (0x01) -->
  <ContentType ID="0x0100839f032740084ac2ae6ea6ab45928a65"
               Name="CustomLogic"
               Group="CustomLogic"
               Description="CustomLogic"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{427E04A8-45E5-4243-BFE9-5FDF6FC6205B}" Name="RFCState" ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{EBC17A5D-F320-43D0-A275-7C657EA6F6C9}" Name="RFCDescription"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{76BF7D5B-6A12-48D1-9827-ADE990B03216}" Name="RFCCompany"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{9C9ED55A-7025-47F4-9637-27D5D2A1BCAE}" Name="RFCDepartment" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{87DA58EB-3C70-4EF4-B833-1D4A93D60AC9}" Name="RFCClient"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{56398822-7A4F-4155-A875-ADD09F32D4F2}" Name="RFCContact"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{A5A5CA1A-6CF4-4BA7-B650-7F06910EA0CD}" Name="RFCAppliesTo"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{47705F89-4883-4AD5-8495-98CE1D4B5C35}" Name="RFCDescriptionCurrent"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{F61E42BC-AEC0-43AA-9AD2-AD7B36C60B22}" Name="RFCDescriptionNew"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{97CD7687-4F16-4AC5-9156-1F178037B5D1}" Name="RFCRisks"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{D424D1B4-4CEA-4E47-B843-6B746EAD1E35}" Name="RFCDemands"  ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{09B7ED41-C5D0-4B8F-B102-F698164A05B9}" Name="RFCExpertise"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="FALSE"/>
      <FieldRef ID="{F7788EA8-A6AD-4009-956A-E756E64D67CC}" Name="RFCImpactanalyses" ShowInEditForm="FALSE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>

      <FieldRef ID="{1A64CE4A-716C-4572-B344-E7CCFE443D50}" Name="RFCScope"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{B131BD67-6B1E-4A40-A916-7C8D9CD17792}" Name="RFCExpectedEffort"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{39BC744E-08D4-410C-9D66-B728221634F5}" Name="RFCOperatingCosts"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{708B111D-F1B2-43BC-89B1-BDFF36C1DB4C}" Name="RFCMotivationAssessment"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{C95F5617-0C01-49F2-AA5C-8ADE757901F4}" Name="RFCPriority"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
      <FieldRef ID="{D6E32A83-D6FD-431B-B2CB-625516D3935F}" Name="RFCDatePlanned"  ShowInEditForm="TRUE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>

      <FieldRef ID="{DB7133D3-96E6-48C5-8B69-76B208FFA5FD}" Name="RFCStatusChanged" ShowInEditForm="FALSE" ShowInNewForm="FALSE" ShowInDisplayForm="TRUE"/>
    </FieldRefs>

    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
        <FormTemplates  xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
          <Display>ListFormChangeManagement</Display>
          <Edit>ListFormChangeManagement</Edit>
          <New>ListFormChangeManagement</New>
        </FormTemplates>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
</Elements>

This is my custom template with a reference to my custom class with the ListFieldIterator overide method.

<%@ Control Language="C#"   AutoEventWireup="false" %>
<%@Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
<%@Register TagPrefix="ApplicationPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.ApplicationPages.WebControls"%>
<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<%@ Assembly Name="CustomOverrideControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92cf2084880c437e" %>
<%@ Register TagPrefix="CustomOverrideControls" Assembly="CustomOverrideControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92cf2084880c437e" namespace="CustomOverrideControls"%>

<SharePoint:RenderingTemplate id="ListFormChangeManagement" runat="server">
    <Template>
        <span id='Span1'>
            <SharePoint:InformationBar runat="server"/>
            <div id="Div1">
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;#160;" runat="server">
                    <Template_RightButtons>
                        <SharePoint:NextPageButton runat="server"/>ssssss
                        <SharePoint:SaveButton runat="server"/>aaaaaf
                        <SharePoint:GoBackButton runat="server"/>ffffffff
                    </Template_RightButtons>
            </wssuc:ToolBar>
            </div>
            <SharePoint:FormToolBar runat="server"/>
            <SharePoint:ItemValidationFailedMessage runat="server"/>
            <table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
            <SharePoint:ChangeContentType runat="server"/>
            <SharePoint:FolderFormFields runat="server"/>
            <%--<SharePoint:ListFieldIterator runat="server"/>--%>
            <CustomOverrideControls:CustomListFieldIterator runat="server"/>
            <SharePoint:ApprovalStatus runat="server"/>
            <SharePoint:FormComponent TemplateName="AttachmentRows" runat="server"/>
            </table>
            <table cellpadding="0" cellspacing="0" width="100%"><tr><td class="ms-formline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td></tr></table>
            <table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px"><tr><td width="100%">
            <SharePoint:ItemHiddenVersion runat="server"/>
            <SharePoint:ParentInformationField runat="server"/>
            <SharePoint:InitContentType runat="server"/>
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;#160;" runat="server">
                    <Template_Buttons>
                        <SharePoint:CreatedModifiedInfo runat="server"/>
                        test1
                    </Template_Buttons>
                    <Template_RightButtons>
                        <SharePoint:SaveButton runat="server"/>test2
                        <SharePoint:GoBackButton runat="server"/>test3
                    </Template_RightButtons>
                    test4
            </wssuc:ToolBar>
            </td></tr></table>
        </span>
        <SharePoint:AttachmentUpload runat="server"/>
    </Template>
</SharePoint:RenderingTemplate>

<SharePoint:RenderingTemplate id="ListForm" runat="server">
    <Template>
        <span id='part1'>
            <SharePoint:InformationBar ID="InformationBar1" runat="server"/>
            <div id="listFormToolBarTop">
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;#160;" runat="server">
                    <Template_RightButtons>
                        <SharePoint:NextPageButton runat="server"/>asdasd
                        <SharePoint:SaveButton runat="server"/>asdasd
                        <SharePoint:GoBackButton runat="server"/>asdasd
                    </Template_RightButtons>
            </wssuc:ToolBar>
            </div>
            <SharePoint:FormToolBar ID="FormToolBar1" runat="server"/>
            <SharePoint:ItemValidationFailedMessage ID="ItemValidationFailedMessage1" runat="server"/>
            <table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
            <SharePoint:ChangeContentType ID="ChangeContentType1" runat="server"/>
            <SharePoint:FolderFormFields ID="FolderFormFields1" runat="server"/>
            <%--<SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server"/>--%>
            <CustomOverrideControls:CustomListFieldIterator runat="server"/>
            <SharePoint:ApprovalStatus ID="ApprovalStatus1" runat="server"/>
            <SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows" runat="server"/>
            </table>
            <table cellpadding="0" cellspacing="0" width="100%"><tr><td class="ms-formline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td></tr></table>
            <table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px"><tr><td width="100%">
            <SharePoint:ItemHiddenVersion ID="ItemHiddenVersion1" runat="server"/>
            <SharePoint:ParentInformationField ID="ParentInformationField1" runat="server"/>
            <SharePoint:InitContentType ID="InitContentType1" runat="server"/>
            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;#160;" runat="server">
                    <Template_Buttons>asdasd
                        <SharePoint:CreatedModifiedInfo runat="server"/>
                    </Template_Buttons>asdasd
                    <Template_RightButtons>
                        <SharePoint:SaveButton runat="server"/>asdasd
                        <SharePoint:GoBackButton runat="server"/>asdasd
                    </Template_RightButtons>asdasd
            </wssuc:ToolBar>asdasd
            </td></tr></table>asdasd
        </span>
        <SharePoint:AttachmentUpload ID="AttachmentUpload1" runat="server"/>
    </Template>
</SharePoint:RenderingTemplate>

1 Answer 1

1

Because you have set Inherits="True" in your content type definition, SharePoint ignores your XmlDocuments section when the solution is deployed, therefore your content type after deployment has no reference to your custom form templates.

The problems with the Inherits attribute have been brought up many times, like here, and here, and many more places.

If you are willing to write a little code (and it seems like you are), I have developed a workaround for this problem, details can be found on my blog.

6
  • Thanks for your fast answer. I have changed the Inherits boolean to False and deploy it to my sharepoint portal. I see some change now, but it is not yet what I am looking for. If I create a new item, I see 0 fields. Also ribon buttions are disabled. Is it my CustomListFieldIterator ?? I have changed the code that it will always return true or false, but didnt help.
    – Ola
    Commented Feb 5, 2013 at 21:21
  • Well, to be honest, I do not have much experience creating custom form templates (yet - I am going to have to do some of that very soon). I just noticed the problem with Inherits, and knew that your custom forms were being ignored. Beyond that I don't know what to tell you, sorry. Commented Feb 6, 2013 at 13:42
  • Thats to bad. Otherwise thanks for your support. Is there someone else who can help me with my custom template?
    – Ola
    Commented Feb 6, 2013 at 15:31
  • This might help, I have had it bookmarked for a while to refer to when I eventually need to start customizing forms: http://pioneeringsharepoint.blogspot.com/2009/11/correct-way-to-customize-forms.html Commented Feb 6, 2013 at 16:13
  • I dont understand step 9, can you please explain?
    – Ola
    Commented Feb 7, 2013 at 9:07

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.