class CommentInformation
A data class representing comment information in SharePoint, including the comment text and mentioned identities.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/comments/information.py
6 - 17
simple
Purpose
CommentInformation is a client-side value object that encapsulates comment data for SharePoint comments. It stores the comment text and a collection of Identity objects representing users mentioned in the comment. This class inherits from ClientValue, making it suitable for serialization and transmission to SharePoint services. It's typically used when creating, updating, or retrieving comment data from SharePoint's commenting system.
Source Code
class CommentInformation(ClientValue):
def __init__(self, text=None, mentions=None):
"""
:param str text:
:param list[Identity] mentions:
"""
self.text = text
self.mentions = ClientValueCollection(Identity, mentions)
@property
def entity_type_name(self):
return "Microsoft.SharePoint.Comments.CommentInformation"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
text: The text content of the comment. This is a string containing the actual comment message. Can be None if not provided during initialization.
mentions: A list of Identity objects representing users who are mentioned/tagged in the comment. Each Identity object contains information about a mentioned user. Can be None or an empty list if no users are mentioned. This parameter is automatically wrapped in a ClientValueCollection for proper handling.
Return Value
Instantiation returns a CommentInformation object with initialized text and mentions attributes. The mentions attribute is always a ClientValueCollection of Identity objects, even if None or an empty list was passed. The entity_type_name property returns the string 'Microsoft.SharePoint.Comments.CommentInformation', which is used for type identification in SharePoint API interactions.
Class Interface
Methods
__init__(self, text=None, mentions=None)
Purpose: Initializes a new CommentInformation instance with optional text and mentions
Parameters:
text: Optional string containing the comment text contentmentions: Optional list of Identity objects representing mentioned users
Returns: None (constructor)
@property entity_type_name(self) -> str
property
Purpose: Returns the SharePoint entity type name for this comment information object
Returns: String 'Microsoft.SharePoint.Comments.CommentInformation' used for SharePoint type identification
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
text |
str or None | The text content of the comment | instance |
mentions |
ClientValueCollection[Identity] | A collection of Identity objects representing users mentioned in the comment | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.sharepoint.comments.client.identity import Identity
Usage Example
from office365.sharepoint.comments.comment_information import CommentInformation
from office365.sharepoint.comments.client.identity import Identity
# Create a simple comment without mentions
comment = CommentInformation(text="This is a great document!")
# Create a comment with mentions
user1 = Identity()
user1.id = "user1@example.com"
user2 = Identity()
user2.id = "user2@example.com"
comment_with_mentions = CommentInformation(
text="@user1 and @user2, please review this.",
mentions=[user1, user2]
)
# Access comment properties
print(comment_with_mentions.text)
print(comment_with_mentions.entity_type_name)
print(len(comment_with_mentions.mentions))
Best Practices
- Always provide valid Identity objects when specifying mentions to ensure proper user tagging
- The mentions parameter is automatically converted to a ClientValueCollection, so you can pass a regular Python list
- This class is immutable after creation in typical usage - create new instances rather than modifying existing ones
- The entity_type_name property should not be modified as it's used by SharePoint for type identification
- When using with SharePoint API, ensure the text content follows SharePoint's comment length and formatting restrictions
- The class inherits from ClientValue, which means it can be serialized for API transmission automatically
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Identity_v1 77.8% similar
-
class Comment 72.1% similar
-
class GetCommentFacet 68.9% similar
-
class CommentCollection 64.8% similar
-
class WebInfoCreationInformation 63.3% similar