Home > SharePoint 2010 > SharePoint 2010: Creating Custom List Definitions that Use InfoPath Forms

SharePoint 2010: Creating Custom List Definitions that Use InfoPath Forms

The general requirement is a “round-trip” of the form you want to add or replace. Before adding or replacing forms in a WSP, they need to be published. Once the form is in a WSP, it can be imported into any Visual Studio project (i.e. a project that defines a custom List definition) and reused. When you publish the form, URLs in the XSF file can be relativized, and other content can be added/removed from XSN components as required by the publish process. We’re proposing the following, for example, when replacing a WSP form:

1. Open the WSP in Visual Studio
2. Locate the XSN in the WSP (there is a standard structure for both list and form library forms).
3. Download a copy of the XSN from SharePoint server using SPD, or make a copy of the XSN that is currently in the WSP.
4. Make the required modifications to the XSN in the InfoPath Designer application
5. Publish the form back to SharePoint
6. Download the XSN from SharePoint using SPD.
7. Replace the XSN in the WSP
8. Repackage/deploy the WSP

That’s the general “life-cycle” and practice. The process below is touching on deploying a SharePoint list form:

If you’ve already upsized a list, before importing the Site WSP into Visual Studio, the XSN will exist in the WSP and can be modified. There is also a process for adding a form to a list definition in a WSP which involves several manual steps. At a high level, the latter involves:

1. Add the XmlDocument to the Schema.xml (under List instances)
2. Under the Modules node, add a new Module (Item_):

  • Name: Lists<name>Item_
  • Modify the Elements.xml file.
  • Remove the “Sample.txt” file added by VS.
  • Add Folders under the created module and add the XSN template so that the path matches the one described in the Elements.xml file

3. Add the Item_pages Module:

  • Name: Lists<name>Item_pages
  • Get the List ID (On the SharePoint server, the link to Add a new list item contains the List ID, it can be copied from there.) <- this step might not be necessary, the deployment process  doesn’t match the list by ID but by name, any GUID would do as long as it’s unique.
  • Ensure the sharePointListID attribute (under the sharepointListAdapterRW node) on the manifest.xsf file matches the GUID “id” value for the Elements.xml file created in this step.
  • Add the property bag to the _pages node.
  • Requires: vti_eTag: maps to the uniqueID for the folder “Lists\<name>\item”.  –> More specifically: PropertyBag refers to the properties of the “item” folder.

4. Add a property bag per item to the modules, one for each:

  • Template.xsn
  • Displayifs.aspx
  • EditIfs.aspx
  • NewIfs.aspx

On the “Features” node add the Modules created before (step 2 & 3: Lists<name>Item_   & Lists<name>Item_pages)

That’s it!

Categories: SharePoint 2010 Tags:
  1. sa
    June 20th, 2010 at 01:27 | #1

    ????
    topic is Creating Custom List Definitions

    and u starting with WSP ? where will u get the WSP man

  2. Reza Alirezaei
    June 20th, 2010 at 01:44 | #2

    @sa
    You customize the list , save the site as a template and you get the wsp.

  3. October 10th, 2010 at 18:19 | #3

    Hi,

    Nice article, I tried it and it works! However I need to hard code the list name. Is it possible to create a reusable custom list template with InfoPath form as new/edit/display form by default using visual studio?

    Thanks

  4. Bruno
    December 30th, 2010 at 20:25 | #4

    Hi… May you upload a sample?

  5. Bruno
    January 5th, 2011 at 09:38 | #5

    Can you upload a example?

  6. میثم
    February 14th, 2011 at 00:33 | #6

    سلام
    بالاخره در این مورد یک اسم فارسی دیدیم
    من نیاز به تغییر
    هایworkitem
    TFS نرم افزار
    دارم.
    مثل این که با
    infopath
    میشه فرمها را به دلخواه خودمون تغییر بدیم
    ولی در این زمینه اطلاعات کافی پیدا نکردم
    من فایل ها را از
    TFS
    دانلود میکنم ولی نمیتونم با
    infopath
    بازش کنم تا تغییرش بدم
    کمکم کنید

  7. میثم
    February 14th, 2011 at 00:36 | #7

    دوباره سلام
    لازم به ذکر است که من
    sharepoint2007 & TFS2010
    را روی یک
    vmware
    نصب کردم
    و
    SQLserver
    را هم را روی شبیه ساز جدا
    لطفا برای
    customize
    کردن این فرمها کمکم کنید

  8. Sean
    June 7th, 2011 at 09:54 | #8

    The list name is hardcoded, which beats the purpose of a List Definition. What if we want to create a re-usable list definition?

  9. Sohaib Khan
    November 24th, 2011 at 07:14 | #9

    Hi Reza,

    Can you please tell me the 2nd process in detail ?

    Thanks

  10. FilipH
    January 5th, 2012 at 08:42 | #10

    First of all, Thank you for taking the time and sharing this knowledge with us.

    I was able to publish the form with this approach, but the behavior of deployed form was very inconsistent.(Republishing the form in infopath created second webpart in list pages etc.) After a week of trying i was unable to move forward. There is barely any information on this topic in books/blogs. I guess, that only way to make this work is to associate the form with list in code somehow. If you have any working sample or info that could be any help to me i would love to hear about it. Even a small bit could help 🙂

You must be logged in to post a comment.