Create, read, update, delete, copy, and export fields (columns) in SharePoint. Fields define the data types used across lists, libraries, and content types.
| Requirement | Description | Reference |
|---|---|---|
| Site Owner role | Required to create, update, and delete site columns. | SharePoint admin roles |
graph TD
subgraph Site
SF["Site Column (web scope)\ne.g. CustomerName"]
end
subgraph "List / Library"
LF["List Column (list scope)\ne.g. InvoiceTotal"]
SF -.->|added as| LF
end
subgraph "Content Type"
FL["Field Link (ordered)\nreferences a field"]
SF -.->|added via| FL
end
A site column (web scope) is defined once and can be reused across lists, libraries, and content types. A list column is scoped to a single list. When a site column is added to a content type, it appears as a field link that defines the display order.
| Operation | File | Required role | API reference |
|---|---|---|---|
| Field inventory: site columns and list columns | inventory.py |
Read access | Fields API |
| Get field details including schema XML | get_field.py |
Read access | Fields API |
| Provision multiple typed fields from a schema spec | provision_fields.py |
Site Owner | Add field |
| Create a lookup field with a dependent lookup | lookup_field.py |
Site Owner | Add lookup |
| Create a taxonomy (managed metadata) field | taxonomy_field.py |
Site Owner | Add taxonomy |
| Update field settings, forms, and indexing | update_field.py |
Site Owner | Update |
| Add a site column to a content type | content_type_fields.py |
Site Owner | Content type fields |
| Copy a field between sites via schema XML | copy_field.py |
Site Owner | Copy |
| Export field definitions to CSV or JSON | export_field_schema.py |
Read access | Fields API |
| Delete a field from a list | delete_field.py |
Site Owner | Delete |
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext("https://contoso.sharepoint.com/sites/team").with_client_secret(
"contoso.onmicrosoft.com", "client_id", "client_secret"
)
# List all site columns (web scope)
fields = ctx.web.fields.get().execute_query()
for f in fields:
print(f" {f.title} (Type: {f.properties.get('TypeDisplayName', '')})")
# Create a text field
field = ctx.web.fields.add_text_field("CustomerName").execute_query()
print(f"Created: {field.title}")