Pages

Sunday, August 23, 2009

How to assign lookup values into List definition – schema.xml file

I had requirements in which I wanted to deploy my custom lists from one server to another server, I had generated my schema and forms files using solution generator tool, now when I open one of my generated schema file in which I have lookup columns linked to another custom list, I have observed that solution generator tool commented custom lookup columns, I mean it didn’t figured out which custom list to attached for lookup columns.

There are many ways to achieve these challenges, one way would be if we know GUID of custom list which we are going to look up on then we can write same GUID into list definition schema file, but in my case all custom list was deployed at same time, so I don’t know what’s GUID of lookup list.

Another solution I found was, we can write feature event receiver on custom list, so when feature install/deploy custom list at same time we can take lookup column list name and assign into lookup columns into list definition file.

But at the last I have found simplest solution to assign lookup values into list definition, there is property called "LIST" into fields columns for schema.xml file, so in same list definition file, we can write List="Name of List" for lookup columns, so it will attached lookup list name for columns.

I hope that above information makes some sense to reader, but if it’s too confusing then please let me know about your challenges we can work out :)

Enjoy!

3 comments:

  1. I'm glad to have found this, we just entered into creating a similar set of list definitions, and we were looking to find out how to accomplish this very thing.

    ReplyDelete
  2. Hi Brian,

    That’s really good that information helps you.

    Thanks,
    Sanket

    ReplyDelete
  3. hi,
    But if the list is in the same web then this will work but if you have a lookup which gets from the rootweb i.e. if we have a sitecolumn then how can we acheive this.

    Regards,
    raghu

    ReplyDelete