Thursday, September 12, 2013

Maintain Look up relationship upon moving list templates from one site to another

Hi,

Problem:- I have come across an issue when I want to move my picture library template from one site to another by keeping the data.The library(say main list) contains one look up column from some other list(say parent list). So,when I was moved my templates and created the Lists on the destination site,the main list lost it's relationship with the parentlist.
Cause :- The reason behind this behavior is the main list referring to parent list through it's id. So, After I moved the stp file also ,the file still referring to the parent list in the source site. 
Solution: - So,solution is straight forward. Open the stp file, replace the list id with list name. However we need to modify the manifest.xml inside stp file. The process is


  •  Get cab file from stp file.
  •  Extract cab file
  •  Modify the manifest xml.
  • Repackage cab file into stp using makecab.exe and ddf file.



The steps to follow:

1. Take out the stp file(say,mainlist.stp)

2. Rename mainlist.stp to mainlist.cab

3. Extract mainlist.cab

4. Locate manifest.xml in the extracted folder and open it using notepad.

5. Find <Field Type="Lookup" List="the id of the parent list" ( ctrl+F , search for <Field Type="Lookup")

6. Replace List="the id of the parent list" with List="Lists/parentlist" and save the file.

7. Create a .ddf file,say list.ddf with the below contents.

   .OPTION EXPLICIT
.Set CabinetNameTemplate=mainlist.stp
.set DiskDirectoryTemplate=CDROM
.Set CompressionType=MSZIP
.Set UniqueFiles="ON"
.Set Cabinet=on
.Set DiskDirectory1=.
.Set CabinetFileCountThreshold=0
.Set FolderFileCountThreshold=0
.Set FolderSizeThreshold=0
.Set MaxCabinetSize=0
.Set MaxDiskFileCount=0
.Set MaxDiskSize=0

8.Open command prompt and go to the folder where you have extracted the cabinet files.

9. Execute dir /b .The list of all file names including manifest.xml will be generated. Copy all filenames from command prompt 

10. Append all file names to the list.ddf file and save the same.

11. Execute makecab /f list.ddf from command prompt.

12.You can see mainlist.stp in the same folder.

13. Upload this stp file into the destination site

14. Create the mainlist which will maintain lookup relationships( Don't forget to create parentlist before that in normal fashion!!!)