Daryl Rasmussen's Not-so-random Thoughts about SharePoint Here in my world

Archive for the ‘Programming’ Category

Tweaking the built-in Survey List

My client wanted to be able to create their own survey that respondants could fill out on-line, and the built-in survey list in SharePoint seemed a likely candidate for doing this (though we did briefly toy with InfoPath as an option as well).

There were a few things about that built-in survey that needed to be tweaked.  Here’s some links that proved useful:

Create List Instance without List Definition

This worked (mostly):


But:  in SP Here at my client’s office, I had to muck about with the Target location (step 6) for the Schema.xml file.   I ended up setting it to the name of the visual studio project, not the name of the list contained there-in.  Also in step 6, file I edited was SharePointProjectItem.spdata, not SharePointItem.data.

Finally, I had to rename the .stp to a .cab not a .zip before I could open the manifest.

In case the link above ever breaks (and also so I have the instructions handy for myself in future), here’s the content of it, replicated for posterity.  Credit is hereby given to the original author, Saurabh Khatri, for a great time saving idea.

Assumtions: I am assuming that we have already created SharePoint Project in Visual Studio 2010.

Preparing Solution Structure

1. In your visual studio instance, Right Click on your sharepoint project and click on Add > New Item.
2. From the Wizard, choose the SharePoint List Instance.
3. a) Give some name your List Instance(Display Name), I will give this ‘MyNewCustomList’
b) Choose a List Template, You can choose any List Template, and choose a List Instance, Let me choose Custom List to keep it simple.
c) Give List a URL, “Lists\MyNewCustomList”
d) Click ok to close the wizard.
4. After step 3, we will be having a SharePointItem  ‘MyNewCustomList’ of type List Instance with a element.xml file, instantiating it from TemplateType=100, that will create a custom list with a Title Column in it. But we wanted to add the fields to this custom schema.(In SharePoint 2010 we can create a List Instance without creating a ListTemplate by specifying CustomSchema property for ListInstance. http://msdn.microsoft.com/en-us/library/ms476062.aspx

<ListInstance Title=”MyNewCustomList” OnQuickLaunch=”TRUE” TemplateType=”100″ Url=”Lists/MyNewCustomList” Description=”My List Instance” CustomSchema=”MyNewCustomList\Schema.xml” />

5. Now Lets Add a Schema.xml File to your SharePointItem.
6. Also include this file into your SharePointItem.data file.
This is how we do it. Click on the your ‘MyNewCustomList’ in Solution Explorer in Visual Studio. Right click Open Folder in Windows Explorer. Open SharePointItem.Data in notepad

<ProjectItemFile Source=”Schema.xml” Target=”MyNewCustomList\” Type=”ElementFile” />

We are done with Solution Preparation steps.

We will now create a Custom List in SharePoint with ”MyNewCustomList”. Go to List Settings and Add the columns, as per the requirement. After doing with all changes whether it is a addition of List Column, Creating a View, addition of some content Type etc.

1. Save this list as Template. Go to Template Gallery, and Download your list template. This file will be a .stp file.\
2. Change the File Extenstion to .zip.
3. Open the zip file, it will contain a manifest.xml
4. Open Manifest.xml file in some nice editor like notepad++.
5. Carefully, Locate node “<List>” in this xml. Copy this entire section of <List>…</List> and now paste it in your schema.xml file we created in above steps.

Few Final Modifications and we are done in Schema.xml file.

1. Remove the name attribute containing List GUID of your previous List.

<List Name=”SomeGUid” …> remove this Name attribute, we don’t need this in our schema

2.Replace the following  nodes <View>

<View BaseViewID=”1″ Type=”HTML” Level=”1″ ContentTypeID=”0x” WebPartZoneID=”Main” OrderedView=”TRUE” DisplayName=”All Links” DefaultView=”TRUE” MobileView=”TRUE” MobileDefaultView=”TRUE” SetupPath=”pages\viewpage.aspx” ImageUrl=”/_layouts/images/links.png” Url=”AllItems.aspx”>

Also replace the Forms Node with the below one.


<Form Type=”DisplayForm” Url=”DispForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />
<Form Type=”EditForm” Url=”EditForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />
<Form Type=”NewForm” Url=”NewForm.aspx” SetupPath=”pages\form.aspx” WebPartZoneID=”Main” />


Great we are done, Now we can include this ListInstance in a feature and create a package. Activating that feature will create a ListInstance.

The first client I used this technique at was on SharePoint 2010.  It worked as well for me in SharePoint 2013 at the next client as well.

Coding External Content Types

I was trying to follow the example given here:


However, it didn’t work for me. This link looked slightly more promising:


But I still was having trouble figuring out in SP Here whether the “External System” shown in Central Admin on the Manage BDC Services page was the LOB Name, or the LOB instance name, or the Model Name, and therefore, confused about what to put in the properties in our specific instance in order to get the Holiday list working from a client’s Dynamics (DAX) based database on the above examples.

To make matters worse, both of the above links, and the post here


say that the format for the EntityNamespace property is supposed to have “dot” notation.

Trial and error and a bit of dogged persistence, and I finally figured it out on my own. The final post above needs 1 correction to make it work (I replied to the author’s post on-line in 2012 when I encountered the issue, but as of Feb 2015, my comments are still not visible there). It took me a few hours to figure this out, but the fact that the documentation here does not mention any prefix or dot-notation should have been my first clue. Basically, you need to change

listDataSource.SetProperty(SPListDataSource.BDCProperties.EntityNamespace, “YourBdc.EntityNamespace”);


listDataSource.SetProperty(SPListDataSource.BDCProperties.EntityNamespace, “EntityNamespace”);

In other words do not prefix the EntityNamespace with “YourBdc.”, or you will get an error that says: Entity (external Content Type) cannot be found with Namespace= “YourBdc.EntityNamespace” , Name = “YourBdcEntity” The error is thrown on the call to list.Add.

Tag Cloud