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 am working in a project with SharePoint Server 2010.

I have the hole project inside a Visual Studio solution (site columns, content types, lists, workflows...)

Everything were working well until I added a lookup field from one of the list in the solution and deployed the solution.

After I deployed the solution, when i try to check my field is OK, i see that the target list in the site column is empty

Site column has selected only the field, but no the list , and I cannot change even with SharePoint Designer

I spend the whole day with this issue, and i cannot find the solutions.

Only if I deploy my solution as a SandBox instead a Farm solutions, my lookup field working well.

Is the any way to do it as a Farm Solution or i must deploy as a sandbox?

Help you guys

share|improve this question
    
Is the lookup field a standard SharePoint lookup field, or something custom? Can you post the xml of the field definition? This is an interesting problem as SharePoint 2010 added the option to specify the name of the list rather than requiring the GUID. –  Chloraphil Mar 14 '13 at 14:44
add comment

2 Answers

Lookup fields need to be provisioned after the parent list, so if you just dump your lookup in with all your other field definitions, it will be broken because the parent list doesn't yet exist when the lookup is provisioned. To ensure your lookups always work put the field element directly beneath the ListInstance element it looks up to.

Whether it is a farm or sandbox solution does not matter. One funny artifact of provisioning your lookups in the wrong order is that it will often succeed on a subsequent deployment, because on the second deployment the list will exist. I suspect that is what you are seeing with your Farm deployment. I'd recommend wiping out your site and starting fresh every time you deploy lists so you don't have these funny dependencies of previously deployed lists.

share|improve this answer
add comment

This may not be a complete answer, but I have run into a similar issue with list templates. If I create a list template in project a, save the template and add it to project b, and then create a new list from that list template in project b, any lookup fields in the new list have to be deleted and recreated. This happens even if I created the lookup list in project b first. I think this is because my lookup list in project a has a unique guid, and the lookup field in my new list in project is expecting a list with the same guid, which doesn't exist in project b.

Again, this doesn't solve your problem, but it may explain why the lookup fields are not working. A possible answer might be something like this:

  1. Create the lookup list first.
  2. Get the guid of the lookup list.
  3. Create the new lookup field in your list.

If you are creating an empty list, that might be all you need. If you are copying a list with data, it gets more complicated.

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.