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

adil 1,371 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

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,393 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,953 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,970 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 48,176 Reputation points Microsoft Vendor
    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.


Your answer

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