Question

I am about to create 84 choice fields for a timesheet solution I am creating in Sharepoint. Clearly I am procrastinating on this task and here I am.

Is there a trick I don't know about that might help with this process?

The columns will have same settings: Choice, Exempt/Non-Exempt, default to blank.

The names obviously will be different, but similar, for example: Non-Exempt, Monday, Week 1 Non-Exempt, Tuesday, Week 1

I already created 84 number fields with similar function and I'm trying to be lazy!

Thanks for any help.

(PS I did a quick search and didn't come up with anything but obviously if there is something already here on this I'd love a link. Cheers!)

Était-ce utile?

La solution

As @Mike pointed out, PowerShell is a very good to option in order to achieve what you want.

One option, is having a .CSV file like this:

enter image description here

Once you have that structure with your data, you can run this PowerShell script to create the columns:

$SiteURL = Read-Host "Input Site URL:"
$CSVPath = Read-Host "Input path to CSV:"
$site = Get-SPSite -Identity $SiteURL
$csv = import-csv -Path $CSVPath
$web = $site.RootWeb

Foreach ($ID in $csv){
    $XML = 
        '<Field
            Type="' + $ID.Type + '"
            Name="' + $ID.Name + '"
            Description="' + $ID.Description + '"
            DisplayName="' + $ID.DisplayName + '"
            StaticName="' + $ID.StaticName + '"
            Group="' + $ID.Group + '"
            Hidden="' + $ID.Hidden + '"
            Required="' + $ID.Required + '"
            Sealed="' + $ID.Sealed + '"
            ShowInDisplayForm="' + $ID.ShowInDisplayForm + '"
            ShowInEditForm="' + $ID.ShowInEditForm + '"
            ShowInListSettings="' + $ID.ShowInListSettings + '"
            ShowInNewForm="' + $ID.ShowInNewForm + '">
        </Field>'

    write-host ""
    write-host $XML
    write-host ""
    $web.Fields.AddFieldAsXML($XML)
    write-host ""
}

Notice that this will only create the columns, if you need to relate some column with some Content Type, this script doesn't make that.

Source: Bulk Creation of SharePoint Site Columns via Powershell

In the case you want to create columns, content types and relate them, you have a very useful tutorial series where steps with code is explained.

  1. Bulk Creation of SharePoint Site Columns and Content Types with PowerShell: Part 1
  2. Bulk Creation of SharePoint Site Columns and Content Types with PowerShell: Part 2
  3. Bulk Creation of SharePoint Site Columns and Content Types with PowerShell: Part 3
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top