Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

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

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.

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

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.