Aug13

Pre-Populate a SharePoint List Instance

 Categories: CAML, Development, SharePoint

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.

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:       <ListInstance FeatureId="89CA0ED1-8E9B-48fa-8C4D-CB406544D662"
   4:                 TemplateType="100"
   5:                 Title="Option List"
   6:                         OnQuickLaunch="TRUE"
   7:                 Description="Choices"
   8:                 Url="Options" >
   9:             <Data>
  10:                   <Rows>
  11:                         <Row>
  12:                               <Field Name="Title">Foo</Field>
  13:                         </Row>
  14:                         <Row>
  15:                               <Field Name="Title">Bar</Field>
  16:                         </Row>
  17:                         <Row>
  18:                               <Field Name="Title">Fred</Field>
  19:                         </Row>
  20:                         <Row>
  21:                               <Field Name="Title">Mildred</Field>
  22:                         </Row>
  23:                         <Row>
  24:                               <Field Name="Title">Karl</Field>
  25:                         </Row>
  26:                         <Row>
  27:                               <Field Name="Title">Lenny</Field>
  28:                         </Row>
  29:                   </Rows>
  30:             </Data>
  31:       </ListInstance>
  32: </Elements>

Hope that someone finds this useful.

Tags:

 

Links to this post

Enterprise Collaboration and Virtual Teams Report (March 7, 2008)

Trackback from Effective Collaboration on 07 Mar 2008 05:07

CKS:EBE Resources

Trackback from thekid.me.uk on 12 Mar 2008 11:58

Comments

Leave a comment