class ListCollectionPosition
A client value class representing a position in a SharePoint list collection, used for pagination control when retrieving list items.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/lists/collection_position.py
4 - 13
simple
Purpose
ListCollectionPosition is a data transfer object that encapsulates pagination information for SharePoint list operations. It inherits from ClientValue and is used to maintain state when iterating through large list collections by storing paging information that tells SharePoint where to continue fetching items from. This is essential for efficient retrieval of list items in batches rather than loading all items at once.
Source Code
class ListCollectionPosition(ClientValue):
def __init__(self, paging_info="Paged=TRUE&p_ID=0"):
"""
:param str paging_info:
"""
self.PagingInfo = paging_info
@property
def entity_type_name(self):
return "SP.ListCollectionPosition"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
paging_info: A string containing SharePoint paging parameters that define the current position in the list collection. Default value is 'Paged=TRUE&p_ID=0' which starts pagination from the beginning. The format follows SharePoint's paging syntax where 'Paged=TRUE' enables paging and 'p_ID' specifies the item ID to start from. This parameter is typically obtained from previous query results to continue pagination.
Return Value
Instantiation returns a ListCollectionPosition object that can be used in SharePoint list queries to control pagination. The object maintains the paging state through its PagingInfo attribute and provides the entity_type_name property which returns 'SP.ListCollectionPosition' for SharePoint API compatibility.
Class Interface
Methods
__init__(self, paging_info: str = 'Paged=TRUE&p_ID=0') -> None
Purpose: Initializes a new ListCollectionPosition instance with pagination information
Parameters:
paging_info: String containing SharePoint paging parameters in the format 'Paged=TRUE&p_ID={id}'. Defaults to starting position.
Returns: None - constructor initializes the instance
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this client value object
Returns: String 'SP.ListCollectionPosition' which identifies this object type in SharePoint API calls
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
PagingInfo |
str | Stores the SharePoint paging information string that defines the current position in the list collection. Format follows SharePoint's paging syntax (e.g., 'Paged=TRUE&p_ID=0'). | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
from office365.sharepoint.lists.collection_position import ListCollectionPosition
# Create a position starting from the beginning
position = ListCollectionPosition()
print(position.PagingInfo) # Output: Paged=TRUE&p_ID=0
print(position.entity_type_name) # Output: SP.ListCollectionPosition
# Create a position to continue from a specific item
position = ListCollectionPosition(paging_info='Paged=TRUE&p_ID=100')
# Typically used with SharePoint list queries:
# list_items = my_list.items.get_all(page_size=100, position=position)
Best Practices
- Use the default paging_info parameter when starting pagination from the beginning of a list
- When continuing pagination, obtain the paging_info string from the previous query result's ListItemCollectionPosition property
- This class is immutable after instantiation - create a new instance with updated paging_info for each pagination step
- The entity_type_name property should not be modified as it's used internally by the SharePoint API for type identification
- Always use this class in conjunction with SharePoint list query operations that support pagination to avoid memory issues with large lists
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ListItemCollectionPosition 89.8% similar
-
class ListItemVersionCollectionPosition 81.1% similar
-
class ListItemCollection 65.3% similar
-
class OrgLabelsContextList 62.8% similar
-
class PermissionCollection 62.8% similar