Pre-Populate a SharePoint List Instance

So, you want to provide a look-up in a SharePoint Site Definition and you’d quite like to provide your users with some options? (i.e. items in the source list)

Firstly you’re probably interested in this post from Josh Gaffy about adding a lookup column declaratively using CAML.

Next you’ll be wanting to use this snippet to declare your source list and the data it will contain.

<Elements xmlns="">
	<ListInstance FeatureId="89CA0ED1-8E9B-48fa-8C4D-CB406544D662"
			Title="Option List"
			Url="Options" >
					<Field Name="Title">Foo</Field>
					<Field Name="Title">Bar</Field>
					<Field Name="Title">Fred</Field>
					<Field Name="Title">Mildred</Field>
					<Field Name="Title">Karl</Field>
					<Field Name="Title">Lenny</Field>

Hope that someone finds this useful.

This entry was posted in CAML, Development, SharePoint. Bookmark the permalink.

3 Responses to Pre-Populate a SharePoint List Instance

  1. Gary says:

    Thanks bro!

  2. Vivien Pipo says:

    thanks but I want to put values in a mutiple values field, I tried

    It does not work. Do you know How to complete that?

    • gavinbarron says:

      The default separator for multivalued items is ;# so value1;#value2;#value3;# may work for you. That said though if your multivalued item is a lookup to another list you’ll need to provide the ID of the item you’re looking up to as well as the value. I can’t recall the pattern for that off the top of my head but if you get stuck then inspect an item you created via the web ui using SharePoint Manager.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.