Search code examples
sharepointdatasourcepowerapps-canvas

Editing a number of lists of a share point site together


I don't know if this is the right place to ask but I am creating a powerapp canvas based app. My data source are saved as share point list files. I have to change the column type from single line of text to Choice for all those list files. As I have a very large number of lists ( Around 100) and each list contains 30-40 columns , changing one by one seems impossible. Is there a way I can change the column type of all the lists at once? Even a way to change the column type of all columns of a single list at once would ease the work a bit!! Please help. If it's not possible directly, is it possible in javascript? can you nudge me to the right direction? Thanks.

list


Solution

  • The easiest way is to run powershell pnp script to update all column types.

    #Set Variables
    $SiteURL = {siteUrl}
    $ListNames = ("List1","List2");
    $ColumnName = "Single"
        
    #Connect to PNP Online
    Connect-PnPOnline -Url $SiteURL -UseWebLogin
         
    ForEach($listName in $ListNames)
    {
       $field = Get-PnPField -List $listName -Identity $ColumnName -Includes FieldTypeKind
       $field.FieldTypeKind = [Microsoft.SharePoint.Client.FieldType]::Choice
       $field.Update()
    }
    Invoke-PnPQuery