2

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!)

  • 1
    use powershell to create your columns. – Mike Jan 31 '18 at 21:23
5

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
  • Wow. Thanks @sergio this is exactly the kind of super helpful answer I was hoping for. I have put off diving in to PowerShell but I can see that it is the way to go for the type of work I now find myself doing. Super great response and I'm sure I'm not the only one who will benefit! – haikuluke Feb 1 '18 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.