1

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

Faf01716
  • 13
  • 3

1 Answers1

0

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
Sergiy Kostenko
  • 273
  • 1
  • 2
  • 11
  • Hi. Thank you for your help. Greatly appreciated. One little thing, What if I want to change the column type of every single column of every single list to the 'choice' type . Is there another way than just putting all the column names one by one in $ColumnName ? – Faf01716 Sep 01 '22 at 10:41
  • Hi, you can get multiple columns and have foreach for columns array. But it is tricky as you may change some irrelevant or system columns. To be safe I would stick to column names. – Sergiy Kostenko Sep 01 '22 at 15:34