class ListItemCreationInformation
A data class that encapsulates the properties required to create a new list item in SharePoint, including file/folder specification, name, and location.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/listitems/creation_information.py
4 - 19
simple
Purpose
This class serves as a data transfer object (DTO) for specifying the properties needed when creating a new list item in SharePoint. It inherits from ClientValue and is used to pass structured information about the item to be created, including whether it's a file or folder, its name, and its target location within a SharePoint list or document library. This class is typically used in conjunction with SharePoint list operations to provide all necessary metadata for item creation in a single, type-safe object.
Source Code
class ListItemCreationInformation(ClientValue):
def __init__(self, leaf_name=None, folder_url=None, underlying_object_type=None):
"""
Specifies the properties of the new list item.
:param int underlying_object_type: Specifies whether the new list item is a file or a folder.
:param str leaf_name: Specifies the name of the new list item. It MUST be the name of the file if the parent
list of the list item is a document library.
:param str folder_url: Specifies the folder for the new list item. It MUST be NULL, empty, a server-relative
URL, or an absolute URL. If the value is a server-relative URL or an absolute URL, it MUST be under the root
folder of the list.
"""
super(ListItemCreationInformation, self).__init__()
self.FolderUrl = folder_url
self.LeafName = leaf_name
self.UnderlyingObjectType = underlying_object_type
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
leaf_name: The name of the new list item to be created. When the parent list is a document library, this MUST be the filename. This is a string value that represents the final name component of the item. Can be None if not specified at initialization.
folder_url: Specifies the target folder location for the new list item. Accepts NULL, empty string, a server-relative URL (e.g., '/sites/mysite/documents/folder'), or an absolute URL. The URL MUST point to a location under the root folder of the target list. Can be None if the item should be created at the list root.
underlying_object_type: An integer value that specifies whether the new list item represents a file or a folder. This determines the type of object being created in the SharePoint list. Can be None if not specified at initialization.
Return Value
Instantiation returns a ListItemCreationInformation object with three public attributes (FolderUrl, LeafName, UnderlyingObjectType) set to the provided parameter values. This object can then be passed to SharePoint list item creation methods.
Class Interface
Methods
__init__(self, leaf_name=None, folder_url=None, underlying_object_type=None)
Purpose: Initializes a new ListItemCreationInformation instance with the specified properties for creating a SharePoint list item
Parameters:
leaf_name: Optional string specifying the name of the new list item or filenamefolder_url: Optional string specifying the target folder location (server-relative or absolute URL)underlying_object_type: Optional integer specifying whether the item is a file (0) or folder (1)
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
FolderUrl |
str or None | Stores the folder URL where the new list item will be created. Can be None, empty, server-relative, or absolute URL within the list's root folder. | instance |
LeafName |
str or None | Stores the name of the new list item. Must be the filename when used with document libraries. | instance |
UnderlyingObjectType |
int or None | Stores the type indicator for the object being created (file vs folder). Typically 0 for files and 1 for folders. | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.listitems.creation_information import ListItemCreationInformation
# Create a new file in a document library
file_creation_info = ListItemCreationInformation(
leaf_name='document.docx',
folder_url='/sites/mysite/Shared Documents/Reports',
underlying_object_type=0 # 0 for file, 1 for folder
)
# Create a new folder
folder_creation_info = ListItemCreationInformation(
leaf_name='NewFolder',
folder_url='/sites/mysite/Shared Documents',
underlying_object_type=1
)
# Access the properties
print(file_creation_info.LeafName) # 'document.docx'
print(file_creation_info.FolderUrl) # '/sites/mysite/Shared Documents/Reports'
print(file_creation_info.UnderlyingObjectType) # 0
Best Practices
- Always specify leaf_name when creating items in document libraries as it represents the required filename
- Ensure folder_url is either None, empty, or a valid server-relative or absolute URL within the list's root folder
- Use underlying_object_type=0 for files and underlying_object_type=1 for folders (if following SharePoint conventions)
- This class is immutable after creation in typical usage - set all properties during instantiation
- The class inherits from ClientValue, which likely provides serialization capabilities for SharePoint API calls
- All parameters are optional at instantiation but may be required by the consuming SharePoint API methods
- This object is typically passed to a SharePoint list's add_item() or similar method, not used standalone
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ListItemCreationInformationUsingPath 94.2% similar
-
class ContentTypeCreationInformation 77.3% similar
-
class CreatableItemInfo 76.9% similar
-
class ViewCreationInformation 75.8% similar
-
class GroupCreationInformation_v1 75.5% similar