Sharepoint - Possible to save a list template and maintain lookup relationships?

I have the same need. I've come across this solution: https://danielthenerd.wordpress.com/2012/06/14/list-template-lookup-by-list-name-not-guid/

Basically, taking the STP, converting it to a CAB, extracting the Manifest.xml, editing it so that the GUID reference is replaced by a name, since the GUID is auto-generated at "run-time".

<Field Type="Lookup" List="Lists/NameOfListToLookup"/>

This works, when creating lists manually (via the UI) - the lookup is preserved.

In our case, I'm trying to create lists via a Visual Studio-generated WSP (feature which dumps the STPs, instantiates lists), with an event receiver to create the lists (List being looked up and another list referring to the first). We were also able to create the lists with the WSP "method".


Not to my knowledge. I've always chalked this up to that when the lists are saved, the look-ups are dropped because there is no guarantee that when the lists are provisioned, that the other dependent list will exist, so it can't save the data.

Something I've been meaning to try is to provision the lookup list first then provision the main list and see if the data will still exist. My inclination is that it won't. However, if you export the main list to Excel, provision the list from the template, then go into datasheet mode, you should be able to paste the data from Excel into the list and be back up and running.


Gary LaPointe has written some particularly ace extensions to stsadm that allow you to import, export, and copy lists (among many other things).

The documentation for these commands can be found here: Import/Export/Copy Lists

I've used these in the past to move lists containing lookups around successfully; I'm pretty sure the lookup values and IDs had an option to be preserved.

Tags:

List