🔍 Code Extractor

class AddFieldOptions

Maturity: 45

A class that defines constant flags for controlling field addition behavior in SharePoint-like list operations.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/add_field_options.py
Lines:
1 - 29
Complexity:
simple

Purpose

AddFieldOptions provides a set of bitwise flag constants that specify how a new field should be added to a list, including whether it should be added to content types, default views, and validation options. This class acts as an enumeration-like container for configuration options when adding fields to SharePoint lists or similar data structures. The flags can be combined using bitwise operations to specify multiple options simultaneously.

Source Code

class AddFieldOptions:
    """Specifies the control settings while adding a field."""

    def __init__(self):
        pass

    DefaultValue = 0
    """Same as AddToDefaultContentType."""

    AddToDefaultContentType = 1
    """Specifies that a new field added to the list MUST also be added to the default content type in the site
    collection."""

    AddToNoContentType = 2
    """Specifies that a new field MUST NOT be added to any other content type."""

    AddToAllContentTypes = 4
    """Specifies that a new field that is added to the specified list MUST also be added to all content types in the
    site collection."""

    AddFieldInternalNameHint = 8
    """Specifies adding an internal field name hint for the purpose of avoiding possible database locking or field
    renaming operations."""

    AddFieldToDefaultView = 16
    """Specifies that a new field that is added to the specified list MUST also be added to the default list view."""

    AddFieldCheckDisplayName = 32
    """Specifies to confirm that no other field has the same display name."""

Parameters

Name Type Default Kind
bases - -

Parameter Details

__init__: The constructor takes no parameters and performs no initialization. The class is designed to be used as a namespace for constant values rather than being instantiated.

Return Value

Instantiating this class returns an AddFieldOptions object, though instantiation is not necessary as all attributes are class-level constants. The class itself serves as a container for integer flag values that can be used directly via the class name (e.g., AddFieldOptions.AddToDefaultContentType).

Class Interface

Methods

__init__(self) -> None

Purpose: Initializes an AddFieldOptions instance, though instantiation is not the intended use pattern

Returns: None - creates an empty instance with no state

Attributes

Name Type Description Scope
DefaultValue int Value of 0. Same behavior as AddToDefaultContentType. Default option when no specific option is provided. class
AddToDefaultContentType int Value of 1. Specifies that a new field added to the list must also be added to the default content type in the site collection. class
AddToNoContentType int Value of 2. Specifies that a new field must not be added to any other content type. class
AddToAllContentTypes int Value of 4. Specifies that a new field added to the specified list must also be added to all content types in the site collection. class
AddFieldInternalNameHint int Value of 8. Specifies adding an internal field name hint for the purpose of avoiding possible database locking or field renaming operations. class
AddFieldToDefaultView int Value of 16. Specifies that a new field added to the specified list must also be added to the default list view. class
AddFieldCheckDisplayName int Value of 32. Specifies to confirm that no other field has the same display name. class

Usage Example

# Using AddFieldOptions flags
from add_field_options import AddFieldOptions

# Use a single option
option = AddFieldOptions.AddToDefaultContentType

# Combine multiple options using bitwise OR
combined_options = AddFieldOptions.AddToDefaultContentType | AddFieldOptions.AddFieldToDefaultView

# Check if a specific option is set using bitwise AND
if combined_options & AddFieldOptions.AddToDefaultContentType:
    print("Will add to default content type")

# Use in a function call (hypothetical API)
# add_field(field_name="MyField", options=combined_options)

# All available options:
# AddFieldOptions.DefaultValue (0)
# AddFieldOptions.AddToDefaultContentType (1)
# AddFieldOptions.AddToNoContentType (2)
# AddFieldOptions.AddToAllContentTypes (4)
# AddFieldOptions.AddFieldInternalNameHint (8)
# AddFieldOptions.AddFieldToDefaultView (16)
# AddFieldOptions.AddFieldCheckDisplayName (32)

Best Practices

  • Do not instantiate this class; use the class-level constants directly (e.g., AddFieldOptions.AddToDefaultContentType)
  • Combine multiple options using bitwise OR operator (|) to specify multiple behaviors
  • Use bitwise AND operator (&) to check if a specific option is set in a combined value
  • The values are powers of 2 (1, 2, 4, 8, 16, 32) to enable bitwise flag operations
  • DefaultValue (0) is equivalent to AddToDefaultContentType behavior
  • AddToNoContentType and AddToAllContentTypes are mutually exclusive options
  • These constants are typically used as parameters when calling SharePoint or similar list management APIs

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ExternalSharingSiteOption 58.7% similar

    A constants class that defines string options for external sharing site permissions in SharePoint or similar collaboration platforms.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/external_site_option.py
  • class FilePickerOptions 58.2% similar

    A configuration class for SharePoint file picker options that extends ClientValue to specify search settings and organizational asset repositories.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/publishing/file_picker_options.py
  • class FieldChoice 56.8% similar

    A specialized Field class that represents a choice field control in SharePoint, used for fields that allow selection from a predefined set of options.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/choice.py
  • class Field 55.2% similar

    A SharePoint Field class that represents metadata containers within SharePoint lists and list items, providing methods to manage field properties, indexing, and form visibility.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/field.py
  • class FieldMultiChoice 54.0% similar

    A SharePoint field class that represents a multi-choice field containing one or more values from a predefined set of choices.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/multi_choice.py
← Back to Browse