Lookup column not link to its Parent list after save list as template

adil 1,431 Reputation points
2024-11-11T15:03:37.3933333+00:00

Hi,

I created two custom lists one 1 .EMP_Department 2.Employee

here in 2nd list i created lookup column linked with 1st list , and i saved two lists as template for reuse in another sub sites in same site collection.

When i tried to create two lists in another sub sites in 2nd list i did not found the lookup column not anymore linking to 1st list

lookup_empty

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Emily Du-MSFT 51,931 Reputation points Microsoft External Staff
    2024-11-12T08:15:26.4833333+00:00

    Because you recreated lists in the subsite, the links of lists are changed, which caused the lookup column to be broken.

    To resolve this issue, you need to recreate the lookup column or repair the lookup column by using PowerShell.

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
     
    #Configuration Parameters
    $SiteURL="subsiteurl"
    $ListName="list2"
    $LookupColumnName="lookupcolumn"
    $LookUpListName="list1" #Parent List
     
    #Get the Objects
    $Web = Get-SPWeb $SiteURL
    $List = $web.Lists[$ListName]
    $LookupList = $web.Lists[$LookUpListName]
    $Column = $List.Fields[$LookupColumnName]
     
    #Update column schema
    $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 "Lookup column fixed!" -f Green
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.