Walkthrough: Deploying a InfoPath 2010 List Form in a Visual Studio 2010 solution package

This is not easy. It took me some days. – Now it works! Smile

Here I’ll show you how to create a List Form for a SharePoint List using InfoPath 2010. Therefore you need SharePoint 2010 Server with Enterprise CALs! – With InfoPath Forms Services it’s possible to render List Forms (“New”, “Edit” and “Display” forms) as browser enabled InfoPath forms. This is really, really cool!

I’ve published the project source code on Codeplex: http://spinfopathlistform.codeplex.com/

Lets start…

1. We create a SharePoint site collection named “http://sharepoint.local/sites/infopathlistform”.

image

2. Now we activate the site collection features:

  • SharePoint Server Enterprise Site Collection features
  • SharePoint Server Standard Site Collection features

image

The enterprise features need to be activated in order to get InfoPath Forms Services working.

3. Open Visual Studio 2010. Create an “Empty SharePoint Project” named “ik.SharePoint2010.InfoPathListFormDemo”.

image

Deploy them as “Farm Solution”.

image

4. Now we add a new project item of type “List Definition” named “Test List 1”.

image

We choose “Custom List” as base type and check “Add a list instance…”

image

5. We open the “Elements.xml” file of the List Instance.

image

We change the List Title and List URL.

image

6.  We edit the “schema.xml” file.

image

We create a list content type with 3 fields.

Here you see the complete content of the “Schema.xml” file.

 <?xml version="1.0" encoding="utf-8"?> 
 <List xmlns:ows="Microsoft SharePoint" Title="Test List 1" FolderCreation="FALSE"
       Direction="$Resources:Direction;"
       Url="Lists/ik.SharePoint2010.InfoPathListFormDemo-TestList1"
       Type="100"
       BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/"> 
   <MetaData> 
     <ContentTypes> 
       <ContentType ID="0x01009A15733A093E44C385EDB29F8E2E1B5A" Name="List Item" Inherits="false"> 
         <Folder TargetName="Item" /> 
         <FieldRefs> 
           <FieldRef ID="{10F8137D-B555-472C-8ACB-B64FF5BEAAF8}" Name="Field_1" /> 
           <FieldRef ID="{84E33CDB-8DDC-4F46-BBF5-845D4071ED41}" Name="Field_2" /> 
           <FieldRef ID="{52680EED-BE6F-478F-A6EC-730398CD626C}" Name="Field_3" /> 
         </FieldRefs> 
       </ContentType> 
       <ContentTypeRef ID="0x0120" /> 
     </ContentTypes> 
     <Fields> 
       <Field ID="{10F8137D-B555-472C-8ACB-B64FF5BEAAF8}" Name="Field_1" StaticName="Field_1"
              DisplayName="Text Field" Type="Text"/> 
       <Field ID="{84E33CDB-8DDC-4F46-BBF5-845D4071ED41}" Name="Field_2"  StaticName="Field_2"
              DisplayName="DateTime Field" Type="DateTime" Format="DateOnly" /> 
       <Field ID="{52680EED-BE6F-478F-A6EC-730398CD626C}" Name="Field_3"  StaticName="Field_3"
              DisplayName="Checkbox Field" Type="Boolean" /> 
     </Fields> 
     <Views> 
       <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="Field_1"></FieldRef> 
           <FieldRef Name="Field_2"></FieldRef> 
           <FieldRef Name="Field_3"></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> 
       <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx"> 
         <Toolbar Type="Standard" /> 
         <XslLink Default="TRUE">main.xsl</XslLink> 
         <RowLimit Paged="TRUE">30</RowLimit> 
         <ViewFields> 
           <FieldRef Name="Attachments"></FieldRef> 
           <FieldRef Name="LinkTitle"></FieldRef> 
           <FieldRef Name="Field_1"></FieldRef> 
           <FieldRef Name="Field_2"></FieldRef> 
           <FieldRef Name="Field_3"></FieldRef> 
         </ViewFields> 
         <Query> 
           <OrderBy> 
             <FieldRef Name="ID"></FieldRef> 
           </OrderBy> 
         </Query> 
         <ParameterBindings> 
           <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /> 
           <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /> 
         </ParameterBindings> 
       </View> 
     </Views> 
     <Forms> 
       <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" /> 
       <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" /> 
       <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pagesform.aspx" WebPartZoneID="Main" /> 
     </Forms> 
   </MetaData> 
 </List>

 

7. The next step is to add an “Empty Element” project item named “Fields”. We add the following content:

 <?xml version="1.0" encoding="utf-8"?> 
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
   <Field ID="{10F8137D-B555-472C-8ACB-B64FF5BEAAF8}" Name="Field_1" StaticName="Field_1"
          DisplayName="Text Field" Type="Text"/> 
   <Field ID="{84E33CDB-8DDC-4F46-BBF5-845D4071ED41}" Name="Field_2"  StaticName="Field_2"
          DisplayName="DateTime Field" Type="DateTime" Format="DateOnly" /> 
   <Field ID="{52680EED-BE6F-478F-A6EC-730398CD626C}" Name="Field_3"  StaticName="Field_3"
          DisplayName="Checkbox Field" Type="Boolean" /> 
 </Elements> 


 

8. Now we deploy the project.

9. Open the site in the browser. Navigate to the “Test List 1”. Select “Edit in SharePoint Designer” from the “Site Actions” menu.

image

10. In SharePoint Designer 2010 open the “Lists and Libraries” from the “Navigation” pane and open the “Test List 1”.

image

In the Ribbon you’ll see the command “Design Forms in InfoPath”.

image

Click the command button and select “List Item” in the drop down menu.

Now InfoPath Designer 2010 opens…

11. In InfoPath Designer 2010 modify the form.

(I will not modify it.)

image

Press the “Publish” button on the Shortcut Menu:

image

12. In SharePoint Designer 2010 choose “All Files” from the “Navigation” pane. Click “Lists”.

image

Click “TestList1”.

image

Click “Item”.

image

Right-click “template.xsn”. Select “Properties…” from the context menu.

image

Select the “Location” from the properties dialog.

image

Copy the URL and open it in a new browser window. You’ll get a “File Download” dialog.

image

Save the file to a temporary location, e.g. to the Desktop.

13. Add a new “Module” project item and name it “Form”.

image

Open a Windows Explorer. Navigate to the Desktop. Drag the file “template.xsn” from the Desktop into the “Form” module inside the Visual Studio project.

Modify the “Elements.xml” file of the “Form” module.

image

14. Add a new “Module” project item and name it “FormPages”.

Into the “Elements.xml” file of this module enter the following code:

 

 <?xml version="1.0" encoding="utf-8"?> 
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
   <Module Name="TestList1Form" Url="Lists/TestList1/Item" SetupPath="pages" RootWebOnly="FALSE" xmlns="http://schemas.microsoft.com/sharepoint/"> 
     <File Url="displayifs.aspx" Type="Ghostable" Path="form.aspx"> 
       <BinarySerializedWebPart> 
         <GUIDMap> 
           <GUID Id="1b8faa0c_4e13_43e7_981f_57d525170d09" ListUrl="Lists/TestList1" /> 
         </GUIDMap> 
         <WebPart ID="{D95DEC48-6F9E-4961-BE47-380AD2870CCA}"
                  List="{$ListId:Lists/TestList1;}"
                  Type="4"
                  Url="Lists/TestList1/Item/displayifs.aspx"
                  WebPartOrder="0"
                  WebPartZoneID="Main"
                  IsIncluded="True"
                  FrameState="0"
                  WPTypeId="{b1dc92e2-8558-f555-ae81-35ed9ddf1644}"
                  Assembly="Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
                  Class="Microsoft.Office.InfoPath.Server.Controls.WebUI.BrowserFormWebPart"
                  AllUsers="B6Dt/iwAAAABAAAAAAAAAAEAAAB+bGlzdC9JdGVtL3RlbXBsYXRlLnhzbgD/ARQrABQCAgIDAgMBBAACAQIJAQEAAggFDEZvcm1Mb2NhdGlvbgUXfmxpc3QvSXRlbS90ZW1wbGF0ZS54c24FDUNvbnRlbnRUeXBlSWQFJjB4MDEwMDdEMTVFNzgxOUUwNDMzNEE4QkY5OTE3OEM1OUNDNjhDBQxMaXN0Rm9ybU1vZGULKaIBTWljcm9zb2Z0Lk9mZmljZS5JbmZvUGF0aC5TZXJ2ZXIuQ29udHJvbHMuV2ViVUkuTGlzdEZvcm1Nb2RlLCBNaWNyb3NvZnQuT2ZmaWNlLkluZm9QYXRoLlNlcnZlciwgVmVyc2lvbj0xNC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj03MWU5YmNlMTExZTk0MjljAQUOU3VibWl0QmVoYXZpb3ILKaQBTWljcm9zb2Z0Lk9mZmljZS5JbmZvUGF0aC5TZXJ2ZXIuQ29udHJvbHMuV2ViVUkuU3VibWl0QmVoYXZpb3IsIE1pY3Jvc29mdC5PZmZpY2UuSW5mb1BhdGguU2VydmVyLCBWZXJzaW9uPTE0LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTcxZTliY2UxMTFlOTQyOWMDAQAAAgICAgU+VXNlIHRoaXMgV2ViIFBhcnQgdG8gZGlzcGxheSBhbiBJbmZvUGF0aCBicm93c2VyLWVuYWJsZWQgZm9ybS4="
                  PerUser="/wEUKwAJAgICAwIBAQAAAgQChAELKjFTeXN0ZW0uV2ViLlVJLldlYkNvbnRyb2xzLldlYlBhcnRzLlBhcnRDaHJvbWVUeXBlAgIEBRZJbmZvUGF0aCBGb3JtIFdlYiBQYXJ0" /> 
       </BinarySerializedWebPart> 
     </File> 
     <File Url="editifs.aspx" Type="Ghostable" Path="form.aspx"> 
       <BinarySerializedWebPart> 
         <GUIDMap> 
           <GUID Id="1b8faa0c_4e13_43e7_981f_57d525170d09" ListUrl="Lists/TestList1" /> 
         </GUIDMap> 
         <WebPart ID="{f811e526-1ad2-4563-b51b-4233f2641a33}"
                  List="{$ListId:Lists/TestList1;}"
                  Type="6"
                  Flags="0"
                  Url="Lists/TestList1/Item/editifs.aspx"
                  WebPartOrder="0"
                  WebPartZoneID="Main"
                  IsIncluded="True"
                  FrameState="0"
                  WPTypeId="{b1dc92e2-8558-f555-ae81-35ed9ddf1644}"
                  Assembly="Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
                  Class="Microsoft.Office.InfoPath.Server.Controls.WebUI.BrowserFormWebPart"
                  AllUsers="B6Dt/iwAAAABAAAAAAAAAAEAAAB+bGlzdC9JdGVtL3RlbXBsYXRlLnhzbgD/ARQrABICAgIDAgMBBAACAQIJAQEAAgYFDEZvcm1Mb2NhdGlvbgUXfmxpc3QvSXRlbS90ZW1wbGF0ZS54c24FDUNvbnRlbnRUeXBlSWQFJjB4MDEwMDdEMTVFNzgxOUUwNDMzNEE4QkY5OTE3OEM1OUNDNjhDBQ5TdWJtaXRCZWhhdmlvcgsppAFNaWNyb3NvZnQuT2ZmaWNlLkluZm9QYXRoLlNlcnZlci5Db250cm9scy5XZWJVSS5TdWJtaXRCZWhhdmlvciwgTWljcm9zb2Z0Lk9mZmljZS5JbmZvUGF0aC5TZXJ2ZXIsIFZlcnNpb249MTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49NzFlOWJjZTExMWU5NDI5YwMBAAACAgICBT5Vc2UgdGhpcyBXZWIgUGFydCB0byBkaXNwbGF5IGFuIEluZm9QYXRoIGJyb3dzZXItZW5hYmxlZCBmb3JtLg=="
                  PerUser="/wEUKwAJAgICAwIBAQAAAgQChAELKjFTeXN0ZW0uV2ViLlVJLldlYkNvbnRyb2xzLldlYlBhcnRzLlBhcnRDaHJvbWVUeXBlAgIEBRZJbmZvUGF0aCBGb3JtIFdlYiBQYXJ0" /> 
       </BinarySerializedWebPart> 
     </File> 
     <File Url="newifs.aspx" Type="Ghostable" Path="form.aspx"> 
       <BinarySerializedWebPart> 
         <GUIDMap> 
           <GUID Id="1b8faa0c_4e13_43e7_981f_57d525170d09" ListUrl="Lists/TestList1" /> 
         </GUIDMap> 
         <WebPart ID="{7319002a-a547-4cdf-8acc-c5ba9cf8a6c9}"
                  List="{$ListId:Lists/TestList1;}"
                  Type="8"
                  Flags="0"
                  Url="Lists/TestList1/Item/newifs.aspx"
                  WebPartOrder="0"
                  WebPartZoneID="Main"
                  IsIncluded="True"
                  FrameState="0"
                  WPTypeId="{b1dc92e2-8558-f555-ae81-35ed9ddf1644}"
                  Assembly="Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
                  Class="Microsoft.Office.InfoPath.Server.Controls.WebUI.BrowserFormWebPart"
                  AllUsers="B6Dt/iwAAAABAAAAAAAAAAEAAAB+bGlzdC9JdGVtL3RlbXBsYXRlLnhzbgD/ARQrABICAgIDAgMBBAACAQIJAQEAAgYFDEZvcm1Mb2NhdGlvbgUXfmxpc3QvSXRlbS90ZW1wbGF0ZS54c24FDUNvbnRlbnRUeXBlSWQFJjB4MDEwMDdEMTVFNzgxOUUwNDMzNEE4QkY5OTE3OEM1OUNDNjhDBQ5TdWJtaXRCZWhhdmlvcgsppAFNaWNyb3NvZnQuT2ZmaWNlLkluZm9QYXRoLlNlcnZlci5Db250cm9scy5XZWJVSS5TdWJtaXRCZWhhdmlvciwgTWljcm9zb2Z0Lk9mZmljZS5JbmZvUGF0aC5TZXJ2ZXIsIFZlcnNpb249MTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49NzFlOWJjZTExMWU5NDI5YwMBAAACAgICBT5Vc2UgdGhpcyBXZWIgUGFydCB0byBkaXNwbGF5IGFuIEluZm9QYXRoIGJyb3dzZXItZW5hYmxlZCBmb3JtLg=="
                  PerUser="/wEUKwAJAgICAwIBAQAAAgQChAELKjFTeXN0ZW0uV2ViLlVJLldlYkNvbnRyb2xzLldlYlBhcnRzLlBhcnRDaHJvbWVUeXBlAgIEBRZJbmZvUGF0aCBGb3JtIFdlYiBQYXJ0" /> 
       </BinarySerializedWebPart> 
     </File> 
   </Module> 
 </Elements>

 

During deployment this creates the form aspx pages that will host the InfoPath Web Part that renders the form at runtime.

In the XML code there are several references to the destination list. All of them have to be set to “Lists/TestList1”. All the code needs to remain unmodified. Don’t change “WPTypeId” attributes! “{b1dc92e2-8558-f555-ae81-35ed9ddf1644}” is the identifier for InfoPath Render Web Part.

BUT change the “ID” attributes of the three “WebPart” tags! Use the “Create GUID” tool from the “Tools” menu of Visual Studio 2010.

15. Now open the “Schema.xml” file of the List Definition project item of “Test List 1”. Add the following code at the before the closing tag of our list content type.

         <XmlDocuments> 
           <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"> 
             <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"> 
               <Display> ListForm</Display> 
               <Edit> ListForm</Edit> 
               <New> ListForm</New> 
             </FormTemplates> 
           </XmlDocument> 
           <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url"> 
             <FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url"> 
               <Display> ~list/Item/displayifs.aspx</Display> 
               <Edit> ~list/Item/editifs.aspx</Edit> 
               <New> ~list/Item/newifs.aspx</New> 
             </FormUrls> 
           </XmlDocument> 
         </XmlDocuments>

 

16. Add another project item of type “Empty Element” named “PropertyBag”. Edit the “Elements.xml” file. Add this code:

 <?xml version="1.0" encoding="utf-8"?> 
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
   <PropertyBag Url="Lists/TestList1/Item/template.xsn"  
                ParentType="File" RootWebOnly="FALSE"  
                xmlns="http://schemas.microsoft.com/sharepoint/"> 
     <Property Name="ipfs_listform" Value="true" Type="string" /> 
     <Property Name="ipfs_streamhash" Value="" Type="string" /> 
   </PropertyBag> 
 </Elements> 

 

This will define the “template.xsn” to be a “InfoPath Forms Services” file (image).

17. Deploy the project.

18. Open the browser and navigate to the “Test List 1”.

Click “Add new item”…

19. HERE WE ARE!

image

But if you enter values and try to save you get this error:

image

This is caused by the missing “Title” field inside the form. This field is marked as mandatory so you need to define it or to remove it from the Content Type and modify the form.

We will do the last one now.

20. In Visual Studio modify the “schema.xml” file of the “Test List 1”. Insert the marked line of code inside the “FieldsRefs” tag of the content type with id starting “0x01…”.

image

Now search for “LinkTitleNoMenu” in the schema.xml file. Replace this “view field reference” with “Edit”.

Now search for “LinkTitle” and replace it with “Edit” too.

21. In Visual Studio look for “template.xsn” in “Form” path in the Solution Explorer. Right-Click the project item and select “Open Containing Folder”.

image

22. In Windows Explorer right-click the file “template.xsn” and click “Design”. The InfoPath 2010 Designer will open.

23. In InfoPath 2010 you’ll see that “Title” cannot be removed. To remove it you would need the edit the xsn file with Notepad: XSN is a CAB file. So you can rename it to cab, extract it’s content, modify the “manifest.xfs” file and compress the folder as CAB file named “template.xsn”… (If you need assistance on this please post as comment.)

In the “Fields” pane select “Title”.

image

(This is the “advanced view” !)

Click the arrow behind the element. Click “Properties” in the context menu.

Uncheck “Cannot be blank”. Click the “OK” button. Save the file. Don’t press “Publish” on the upcoming dialog. Just press “Save”!

Quit InfoPath.

Deploy the project.

24. In Internet Explorer refresh you site and add a new item to the “Test  List 1”.

You’ll see: the “Title” column is gone. Now we have a “Edit item” column on the list view.

Now add an item.

image

Save it.

25. HERE WE ARE AGAIN!

It works for me now!

image

Just for testing purpose select the list item and click “View Item” on the Ribbon.

You will see the list item in a read-only InfoPath browser form!! – If you click “Edit” on the Ribbon, you’ll be able to edit the item.

46 thoughts on “Walkthrough: Deploying a InfoPath 2010 List Form in a Visual Studio 2010 solution package”

  1. Hi Ingo Karstein its really good stuff
    Now I’ve one query for same. If i want to add more columns to my list definition then each time i’ve to update template.xsn file? Please help me for above query.

    1. Hi Jay!

      You have to modify the template.xsn every time you modify the underlying list. Or you recreate the XNS by using SharePoint Designer 2010 and create another list form. This you can extract using SPD as described in the article.

      Ingo

  2. This solution works if you name your list “TestList1”. This is a list definition, what if the user name’s the list that he/she creates as “TestList2”, this will not work as the Module will deploy the Template.xsn and aspx files to Lists/TestList1… ?

    1. Hi!

      You should work with site event receivers to capture “List added” events and assign the list form by code. – I’ll see to create a tutorial on this, but this may take me a while because of another project for this blog.

      Ingo

    1. Hi!

      it’s reusable with modifications. You need to execute some code after creating a list. I think a site event receiver for “List added” would help. In the event receiver I would assign the form to the created list…

      Ingo

  3. Hey!

    I’m trying out your solution, and adapting it to the list I’m deploying

    In your elements.xml file for the FormPages module, you have:

    Doesn’t this need to be updated to reflect the my deployment???

    Hope you can help! 🙂
    Great article!

      1. Doh! now – where did the code go?

        Ok, what I was asking was: you have in the elements.xml file for the FormPages module, and xml node called GUIDmap and in that a GUID node – that guid you have there – shouldn’t that reflect something in my deployment? or is that some generic guid?

        Thanks!
        /Jesper

  4. Hi Ingo, Julius here.

    I was wondering how to go about having a code-behind in the InfoPath form page that serves as list forms?

  5. Hi there,

    I am trying to test this solution (as it is in a first place) and it deploys no problem.
    But once i go in my list and do “add new item” (step 18).

    I get the following error :
    **********************************************************************
    The file or folder name contains characters that are not permitted. Please use a different name.0x81020073

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: The file or folder name contains characters that are not permitted. Please use a different name.0x81020073

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [COMException (0x81020073): The file or folder name contains characters that are not permitted. Please use a different name.0x81020073]
    Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion, String& pbstrTimeLastModified, String& pbstrContent, Byte& pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder) +0
    Microsoft.SharePoint.Library.SPRequest.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion, String& pbstrTimeLastModified, String& pbstrContent, Byte& pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder) +589

    [SPException: The file or folder name contains characters that are not permitted. Please use a different name.]
    Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27257906
    Microsoft.SharePoint.Library.SPRequest.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion, String& pbstrTimeLastModified, String& pbstrContent, Byte& pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder) +27638031
    Microsoft.SharePoint.SPWeb.GetWebPartPageContent(Uri pageUrl, Int32 pageVersion, PageView requestedView, HttpContext context, Boolean forRender, Boolean includeHidden, Boolean mainFileRequest, Boolean fetchDependencyInformation, Boolean& ghostedPage, Byte& verGhostedPage, String& siteRoot, Guid& siteId, Int64& bytes, Guid& docId, UInt32& docVersion, String& timeLastModified, Byte& level, Object& buildDependencySetData, UInt32& dependencyCount, Object& buildDependencies, SPWebPartCollectionInitialState& initialState, Object& oMultipleMeetingDoclibRootFolders, String& redirectUrl, Boolean& ObjectIsList, Guid& listId) +1750
    Microsoft.SharePoint.ApplicationRuntime.SPRequestModuleData.FetchWebPartPageInformationForInit(HttpContext context, SPWeb spweb, Boolean mainFileRequest, String path, Boolean impersonate, Boolean& fGhostedPage, Byte& verGhostedPage, Guid& docId, UInt32& docVersion, String& timeLastModified, SPFileLevel& spLevel, String& masterPageUrl, String& customMasterPageUrl, String& webUrl, String& siteUrl, Guid& siteId, Object& buildDependencySetData, SPWebPartCollectionInitialState& initialState, String& siteRoot, String& redirectUrl, Object& oMultipleMeetingDoclibRootFolders, Boolean& objectIsList, Guid& listId, Int64& bytes) +26191009
    Microsoft.SharePoint.ApplicationRuntime.SPRequestModuleData.GetFileForRequest(HttpContext context, SPWeb web, Boolean exclusion, String virtualPath) +608
    Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.InitContextWeb(HttpContext context, SPWeb web) +132
    Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) +564
    Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextWeb(HttpContext context) +27
    Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PostResolveRequestCacheHandler(Object oSender, EventArgs ea) +918
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
    **********************************************************************************

    Do you have an idea what could this be?
    I have made some research on the internet but there are always talking about feature activation but here the feature is activated.

    Thanks for your help,
    Jen

        1. Since no one bothered to answer this, I will save others the hassle. The ~Lists in the section:

          ~list/Item/displayifs.aspx <—
          ~list/Item/editifs.aspx <—
          ~list/Item/newifs.aspx <—- Change all three to Lists/TestList1/(the rest the same)

          It is complaining about the ‘~’ character. I don’t understand why it works the first time (sometimes), but at some point it will complain.

          Hope this helps.

    1. SOLUTION!!!

      I hope this helps, it works for me
      illegal characters is due to 15) step
      it is the first space in nodes

      ListForm <— DELETED SPACE
      ListForm <— DELETED SPACE
      ListForm <— DELETED SPACE

      ~list/Item/displayifs.aspx <— DELETED SPACE
      ~list/Item/editifs.aspx <— DELETED SPACE
      ~list/Item/newifs.aspx <— DELETED SPACE

  6. I followed the instrutions until Step 18, an exception is thrown: Form control does not have ControlMode set.
    Do you have any idea?

    Li

    1. I’m having the same issue..getting a “Form control does not have ControlMode set.” What was the solution to this?

  7. Hey! So, how do you use this in a document library list definition? I found this blog, http://www.spindepth.com/2011/04/infopath-sharepoint-document-library.html?showComment=1320767295962#c1493910595178281814, which has a video that shows how to edit the document library’s new/edi/display form, in combination with your walkthrough. It deploys but when I try to use it, either there is no form that appears (in the case of edit) or I get “webpage cannot be found” (in the case of the new form that appears after a document is uploaded). Thanks!

  8. Hello Ingo,

    If i create my own content type and list instance then your logic doesn’t work. There is something which you’ve done and might be forgot to write. May i know how can i do this ?

    Thanks,

  9. Hello Ingo,

    I hope you’re fine. I’ve followed your example. It works fine. But, If i develop my custom content type (let say SKcontenttype) then it throws message:
    “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file.”

    After developing the custom content type using Visual Studio, I changed all the references of ‘Item’ to ‘SKcontenttype’. It deploys the form fine but when i click on ‘Add new item’ then it throws error message on infopath dialog box which is “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file”. There is no issue with the permission as i’m using Admin account on my VM.

    I checked the ULS logs and found out that the FormLocation in all the 3 aspx pages (newifs.aspx, editifs.aspx, displayifs.aspx) refers to ‘Item’ content type which is wrong. How can i fix this ?

    Thanks

  10. Hi when i Follow the above approach, I faced the error

    The file or folder name contains characters that are not permitted. Please use a different name.0×81020073

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: The file or folder name contains characters that are not permitted. Please use a different name.0×81020073

    could any one let me know what could be the issue with. (my list names are like this (“HSTLST-ContactInfo”), Is this is the reason i suspect.

  11. There has been an error while loading the form.

    Click Try Again to attempt to load the form again. If this error persists, contact the support team for the Web site.

    Click Close to exit this message.

    Hide error details
    A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file.

    Correlation ID:e3641c9a-8cb9-4476-9d07-bcce3533fed4

    while adding a new item after deploying the solution, now iam getting the above error. Could any one please tell what could be
    the issue iam facing here.

  12. Bonjour,

    Pour corriger l’erreur :
    “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file.
    Correlation ID:e3641c9a-8cb9-4476-9d07-bcce3533fed4 ”

    Vous devez écrire celà :

    A la place de:

    Cordialement,
    Sabri

    1. Comment corriger l’erreur “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file” svp ?

      Could anyone tell how to resolve the issue “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file” ?

      1. sam-

        if you use InfoPath forms you need to modify the workflow config xml inside the archive. Before you replace the config file as described in my article you need to insert the reference to the InfoPath form.

        kind regards
        ingo

        1. Hi Ingo,

          I was encouraged to see there was an article on this topic. However, I too receive the error “A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file”. I have followed your steps verbatum.

          Can you please clarify your response? “workflow config xml inside the archive”?

          Thanks a lot!

          -Marc

          1. Hi Marc,

            you may be forgot to merge some files. The XSNs are in the package. I would recommand to extract the original package and the modified package and compare them by using a tool, e.g. WinDiff. I’m almost sure you will find diffrences in files or in the folder structure.
            The XSNs are registered in one of the XML files. You need to merge the files into the package as well as the references in the XML.

            Regards
            Ingo

          2. Thank you Ingo. I spent more time tinkering with the template location and found when the template is published to “Lists/TestList1/Item” as opposed to “Lists/TestList1/Item/Form”, it works! However, that was a manual process. I will review the steps again. I’m sure there is a programmatic way to publish the form to a specific location.

  13. Hi,

    This is very good article and i tried this one.
    I am able to deploy successfully but once i try to add new item, i am getting 404 page not found error. i am suspecting that, mapping is missed to the xsn file. Could you please tell me where i am doing wrong.

    Thanks.

  14. Does this work for custom Workflow Tasks List with Custom Content Types? I have a custom workflow task list with multiple content types. I want to be able to have custom edit forms in InfoPath for each of the content type.

    When I tried following the steps above, i get the following error: Form control does not have ControlMode set.

    Creating a Test List with Custom List works fine. But this is not working for custom infopath forms in Workflow Tasks List with custom content types.

  15. This is really great post with detailed explanation. And I have one more question- I tried this process on my test site and it worked. But If I want to deploy this package to production (with different domain), how do I need to proceed? And my infopath form has dataconnections to a list (which also exists in prod), how do I go about dealing with them? How does it map the http://stage1/lists/custom/ to http://prod/lists/custom?

  16. It looks like this solution is not viable for lists with multiple content types because the BinarySerializedWebPart modules are not able to adjust the FormLocation attribute for the webpart… unless of course I am missing something.

  17. Hi ikarstein ,

    I got the following error when trying to open the new form newifs.aspx,
    No XsltListViewWebPart was found on this page.

    Do you have any idea why this error occurs?

    Thanks,
    Suparna

  18. Hi ikarstein ,

    I got the following error when trying to open the new form newifs.aspx,
    No XsltListViewWebPart was found on this page.
    Do you have any idea why this error occurs?

    Thanks,
    Suparna

  19. Hi ikarstein ,

    I get the following error when trying to open the new form “newifs.aspx”,
    No XsltListViewWebPart was found on this page.
    Do you have any idea why this error occurs?

    Thanks,
    Suparna

  20. Ingo,

    I’ve got everything working except that when I add a data connection (from SharePoint list on same site as the custom list form or to a UDC file in a data connection library on the same site) I get an error when I query that data connection either in the form load or using an action rule on a button. With InfoPath Form Services logging set to verbose I get the following entries at the time the form attempts to query the data connection:

    – There was a form postback error. Exception Message: Object reference not set to an instance of an object

    – Unhandled exception in FormServer: Object reference not set to an instance of an object.. Type: System.NullReferenceException. StackTrace: at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.UrlIsSameFileOrSamePath(String absoluteFileUrl, String baseFileOrFolderUrl) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.IsSolutionMoved(Document document) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.GetList(WebHolder webHolder, Boolean impersonatedIdentity, Document document, String siteUrl, Boolean isUrlSetThroughOM, Guid listId) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.c__DisplayClasse.b__3(Boolean impersonatedIdentity) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterUtil.Impersonate(DataAdapterInformation adapterInfo, String userName, String userDomain, String password, CodeToRunUnderImpersonation codeToRun) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterUtil.Impersonate(DataAdapterInformation adapterInfo, String userName, String password, CodeToRunUnderImpersonation codeToRun) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.Execute(String siteUrl, Guid listId, SPContentTypeId contentTypeId, Document document, DataAdapterListDataProvider documentAdapter, Boolean useDcl, XPathNavigator queryFields, XPathNavigator resultFields, Boolean isListItemEditing, Boolean discoveryOnly, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataAdapterListDataProvider.ExecuteInternal(XPathNavigator queryFields, XPathNavigator resultFields, Boolean useListItemMode) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RuleAction.EvaluateExpression(Document document, XPathNavigator currentTarget) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesRuleSet.EvaluateExpression(Document document, XPathNavigator targetNavigator) at Microsoft.Office.InfoPath.Server.SolutionLifetime.ButtonFormCode.Click(Document document, XPathNavigator container) at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventClick.Play(Document document, BindingServices bindingServices, EventLogProcessor eventLogProcessor) at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventLogProcessor.ExecuteLog(Int32 expectedEventLogID) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.c__DisplayClass13.b__11() at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock) 32ce0507-3a47-42a8-adb5-8fcf8f6f97c7

    – Unhandled exception when rendering form on postback System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.UrlIsSameFileOrSamePath(String absoluteFileUrl, String baseFileOrFolderUrl) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.IsSolutionMoved(Document document) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.GetList(WebHolder webHolder, Boolean impersonatedIdentity, Document document, String siteUrl, Boolean isUrlSetThroughOM, Guid listId) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.c__DisplayClasse.b__3(Boolean impersonatedIdentity) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterUtil.Impersonate(DataAdapterInformation adapterInfo, String userName, String userDomain, String password, CodeToRunUnderImpersonation codeToRun) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterUtil.Impersonate(DataAdapterInformation adapterInfo, String userName, String password, CodeToRunUnderImpersonation codeToRun) at Microsoft.Office.InfoPath.Server.SolutionLifetime.DataAdapterListDataProvider.Execute(String siteUrl, Guid listId, SPContentTypeId contentTypeId, Document document, DataAdapterListDataProvider documentAdapter, Boolean useDcl, XPathNavigator queryFields, XPathNavigator resultFields, Boolean isListItemEditing, Boolean discoveryOnly, Int64& auxDomSize) at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataAdapterListDataProvider.ExecuteInternal(XPathNavigator queryFields, XPathNavigator resultFields, Boolean useListItemMode) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RuleAction.EvaluateExpression(Document document, XPathNavigator currentTarget) at Microsoft.Office.InfoPath.Server.SolutionLifetime.RulesRuleSet.EvaluateExpression(Document document, XPathNavigator targetNavigator) at Microsoft.Office.InfoPath.Server.SolutionLifetime.ButtonFormCode.Click(Document document, XPathNavigator container) at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventClick.Play(Document document, BindingServices bindingServices, EventLogProcessor eventLogProcessor) at Microsoft.Office.InfoPath.Server.DocumentLifetime.EventLogProcessor.ExecuteLog(Int32 expectedEventLogID) at Microsoft.Office.InfoPath.Server.DocumentLifetime.Document.c__DisplayClass13.b__11() at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock) 32ce0507-3a47-42a8-adb5-8fcf8f6f97c7

  21. I m working in SharePoint designer2013,Visual studio2012 ,infopath2013 and sharepoint2013.while deploying the solution the template.xsn file placed in items. But normal form only displayed when I m clicking the new item. Please help me display the template.xsn form. I spent more than 2 days for this concepts…

  22. Hi ikarstein ,

    I got the following error when trying to open the new form newifs.aspx,
    MetadataNavigationContext Page_InitComplete: No XsltListViewWebPart was found on this page.
    Do you have any idea why this error occurs?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *