Forum Discussion

jbtzz's avatar
jbtzz
Brass Contributor
Mar 21, 2023
Solved

Identify site columns in lists

Good day,

 

Is there a way to know which columns in a list are actually site columns and not "locally" created list columns?

  • I figured it out by using PowerShell PnP:

    #Parameters
    $SiteURL = "https://YourDomain.sharepoint.com/sites/YourSite"
    $ListName = "YourListName"
    
    #Connect to source SharePoint
    Connect-PnPOnline -Url $SiteURL -Interactive
    
    #Get list and site columns to compare Ids
    $ListFields = Get-PnPField -List $ListName
    $SiteFields = Get-PnPField
    
    Foreach($l in $ListFields | where {$_.Hidden -eq $false}){
        $counter = 0
        Foreach($s in $SiteFields){
            if($l.Id -eq $s.Id) {
                echo "$($l.Title) (Internal name: $($l.InternalName)) is a SITE COLUMN"
                $counter++
            }
        }
    
        if($counter -eq 0){
            echo "$($l.Title) (Internal name: $($l.InternalName)) is a LIST COLUMN"
        }
    }

     

5 Replies

  • jbtzz's avatar
    jbtzz
    Brass Contributor

    I figured it out by using PowerShell PnP:

    #Parameters
    $SiteURL = "https://YourDomain.sharepoint.com/sites/YourSite"
    $ListName = "YourListName"
    
    #Connect to source SharePoint
    Connect-PnPOnline -Url $SiteURL -Interactive
    
    #Get list and site columns to compare Ids
    $ListFields = Get-PnPField -List $ListName
    $SiteFields = Get-PnPField
    
    Foreach($l in $ListFields | where {$_.Hidden -eq $false}){
        $counter = 0
        Foreach($s in $SiteFields){
            if($l.Id -eq $s.Id) {
                echo "$($l.Title) (Internal name: $($l.InternalName)) is a SITE COLUMN"
                $counter++
            }
        }
    
        if($counter -eq 0){
            echo "$($l.Title) (Internal name: $($l.InternalName)) is a LIST COLUMN"
        }
    }

     

  • jbtzz 

     

    When you click on the column name in list settings it will not tell you whether it's a site column. If you enable content management on a library, go into the content type, and click on a column name, it will tell you if the column is inherited from a site column because you won't be able to edit it, and it will provide a link to edit the site column.

     

    If I have answered your question, please mark your post as Solved

    If you like my response, please give it a Like :smile:

    Appreciate your Kudos! Proud to contribute! ğŸ™‚

     

    • jbtzz's avatar
      jbtzz
      Brass Contributor
      Thanks for the quick reply.

      Unfortunately, that doesn't work. I imported a site column to the list and created another column locally. Both have the same behavior, and I can edit the site column from the content type screen you showed.
      • Deleted's avatar
        Deleted

        jbtzz 

         

        Another way to identify site columns in lists is by using the name of the column. 

         

        But the best way is 

        • If it's a site column you will be able to use it on other lists
        • If it's a list column, it's only limited to that list, you can't use it on other lists

        If I have answered your question, please mark your post as Solved

        If you like my response, please give it a Like :smile:

        Appreciate your Kudos! Proud to contribute! ğŸ™‚

         

Resources