SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two lists. The first one has customers and the second one has Orders. Now i want to add some (test) data in the elements.xml of the listinstances. For customers this works without a problem

      <Field Name="Id">1</Field>
      <Field Name="FirstName">Beni</Field>
      <Field Name="LastName">Egli</Field>

Now I want to do the same for the orders. An order is linked to a customer via a lookupfield. I also want to set the date to (for example) today.

      <Field Name="Id">1</Field>
      <Field Name="CustomerLookup">2</Field>
      <Field Name="Date">[today]</Field>

The Date=[Today] can't even deploy and when I remove the date line no entries are added (date is not required)

share|improve this question
how did u create Date Field? I think u should set default value when u r creating ur field – user7676 Apr 3 '12 at 8:19
I agree, set the Date field to have a default value of Today/Now. – Ian Apr 3 '12 at 9:25
You could also inject data on feature activated, then you have full control of what and how you add data – eirikb Sep 12 '12 at 6:14

This will not work because Sharepoint will eventually put every list item in the same table in the database. The order item will not be added since an item with ID=1 already exists. (the customer item).

It is not recommended to add list items this way, and as suggested above you could use a feature event receiver to add items instead.

If you would like to use the xml make sure that the ids do not match. This can be tricky when you get a lot of lists and items in them.

share|improve this answer

I don't know about the lookup field but for date field you can write this way:

  <Field Name="Id">1</Field>
  <Field Name="Date">2011-12-30T21:00:00Z</Field>

Refer this discussion for more details.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.