First published on TECHNET on Sep 06, 2013
This post is a contribution from Aaron Miao, an engineer with the SharePoint Developer Support team.
1. We create a SharePoint site collection named http://intranet.contoso.com/sites/testsite/testexternallist.
**It’s good to use a site which does not have lot of stuffs, best would be to create a new team site or blank site.
2. Activate the following site collection features:
a. SharePoint Server Enterprise Site collection features
b. SharePoint Server Standard Site collection features
**You could use Northwind sample database
3. Create a table in SQL database called TestTable .
4. Add some data to it.
5. Open the test site using SPD 2013 and create an external content type ExternalTestCT ( reference if you need it).
6. Create external list using SPD 2013 and choose to create InfoPath forms.
The result should look like this.
7. Verify external list works by browsing to it using SharePoint 2013 UI.
8. Make sure the external list displays data successfully in InfoPath forms. “View Item” of the list will display an item in InfoPath form like this:
9. Now save the site as template without content using SPD 2013.
10. This will generate a WSP file in your site collection solution gallery. Download a copy of this WSP and save it to local disk.
11. Create a Visual Studio 2013 project of type “SharePoint 2013 – Import Solution Package” and point to the saved WSP. As a reference, this blog walks through the entire process.
**When there’s a warning about dependencies, click “Yes” to have VS 2012 automatically include all dependencies.
12. Once you are done with these steps, you will have the external list instance, with its schema. You will also have Modules with all the InfoPath forms and template.xsn. In addition, you’ll see a PropertyBags module as well. Your project should look like this:
13. Clean up unnecessary files
a. Remove ListsExternalList1_pages item
b. Remove 2 features (3 features are imported. Retain the first feature you see from the top in the list of features and remove the other 2)
c. Make sure the feature includes items: List instances, Modules and PropertyBags.
In the end, your project should look like this:
**Make sure you verify that the external list name is same in the list instance and all the files (schema, module files). There are lots of places the list name and its URL is used.
14. ExternalList1/Elements.xml:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ListInstance FeatureId="{00bfea71-9549-43f8-b978-e47e54a10600}" TemplateType="600" Title="ExternalList1" Description="" Url="Lists/ExternalList1" CustomSchema="Files\Lists\ExternalList1\Schema.xml" HyperlinkBaseUrl="http://spdev1505/sites/TestSite" RootWebOnly="FALSE" xmlns="http://schemas.microsoft.com/sharepoint/"> <DataSource> <Property Name="Entity" Value="ExternalTestCT" /> <Property Name="EntityNamespace" Value="http://spdev1505/sites/testsite" /> <Property Name="LobSystemInstance" Value="testdb" /> <Property Name="SpecificFinder" Value="Read Item" /> </DataSource> </ListInstance> </Elements>
**<DataSource> provides information of the generated BDC model.
15. ExternalList1/Schema.xml:
<List Title="ExternalList1" Direction="none" Url="Lists/ExternalList1" BaseType="0" Type="600" MultipleDataList="FALSE" DontSaveInTemplate="TRUE" DisableGridEditing="TRUE" NoCrawl="TRUE" DisallowContentTypes="TRUE" BrowserFileHandling="permissive" NavigateForFormsPages="TRUE" FolderCreation="FALSE" DisableAttachments="TRUE" Catalog="FALSE" SendToLocation="|" ImageUrl="/_layouts/15/images/itebl.png?rev=23" xmlns:ows="Microsoft SharePoint" xmlns:spctf="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms" xmlns="http://schemas.microsoft.com/sharepoint/"> <MetaData> <Fields> <Field DisplayName="BDC Identity" Hidden="FALSE" Name="BdcIdentity" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="BdcIdentity" Type="Text" ReadOnly="TRUE" /> <Field DisplayName="TextCol" Hidden="FALSE" Name="TextCol" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="TextCol" Type="Text" ReadOnly="TRUE" Required="TRUE" /> <Field DisplayName="DateCol" Hidden="FALSE" Name="DateCol" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="DateCol" Type="DateTime" /> <Field DisplayName="BoolCol" Hidden="FALSE" Name="BoolCol" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="BoolCol" Type="Boolean" /> </Fields> <Forms /> <Views> <View DisplayName="ExternalTestCT Read List" DefaultView="TRUE" BaseViewID="1" Type="HTML" MobileView="TRUE" MobileDefaultView="TRUE" ImageUrl="/_layouts/15/images/generic.png?rev=23" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="0" Url="Read List.aspx" SetupPath="pages\viewpage.aspx"> <XslLink>main.xsl</XslLink> <Method Name="Read List" /> <Query> <OrderBy> <FieldRef Name="TextCol" /> </OrderBy> </Query> <ViewFields> <FieldRef Name="TextCol" ListItemMenu="TRUE" LinkToItem="TRUE" /> <FieldRef Name="DateCol" /> <FieldRef Name="BoolCol" /> </ViewFields> <RowLimit Paged="TRUE">30</RowLimit> <Aggregations Value="Off" /> </View> </Views> </MetaData> </List>
**Type=”600” indicates this is an external list. Fields are defined in the schema.
16. Modules/ListsExternalListItem_/Files/Elements.xml:
17. PropertyBags/Elements.xml:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <PropertyBag Url="Lists/ExternalList1/Item/template.xsn" ParentType="File" RootWebOnly="FALSE" HyperlinkBaseUrl="http://spdev1505/sites/TestSite" AlwaysCreateFolder="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/"> <Property Name="ipfs_streamhash" Value="WilYbGIFAHARhhugf7kJzQlo447iT2RkT/siF5/CimI=" Type="string" /> <Property Name="vti_streamschema" Value="66" Type="int" /> </PropertyBag> </Elements>
**There are many properties in the file generated originally. Only the above two are required. Looks like they are related to InfoPath form activation and file persistence.
In the end, you should see the artifacts like in the VS 2012 project attached to this blog post.
18. Deploy the project to another site. You may not see the external list in the quick launch. Navigate to site contents and click the external list. You should see the list and InfoPath item view form.
19. The view form URL should like like what’s shown below. Notice that displayifs.aspx is used and not DispForm.aspx .
Hope this post was helpful!
Sample VS2012 project for download
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.