One of the common issues when creating a new site from a site Template is that the lookup columns values are blanks. The full scenario is as below :
- Create a SharePoint site
- Add lists with lookup columns
- Insert some data in the lists
- Save the site as Template with its content
- Create a new site from the Template
- The Web Id
- The List Id
- Using C#
- Using Powershell
$web = Get-SPWeb "Your web url"
$list = $web.Lists["Your list name"]
$column = $list.Fields["Your column name"]
$lookupList = $web.Lists["Your source list name"]
#Updating the column properties
$column.SchemaXml = $column.SchemaXml.Replace($column.LookupWebId.ToString(), $web.ID.ToString())
$column.SchemaXml = $column.SchemaXml.Replace($column.LookupList.ToString(), $lookupList.ID.ToString())
$column.Update()
write-host "Column properties have been updated"
$Web.Dispose()
More details about the lookup columns on MSDN.
Enregistrer un commentaire