🔍 Code Extractor

class DocumentsSharedWithMe

Maturity: 49

A SharePoint class that provides static methods for retrieving documents shared with the current user on their personal site.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/userprofiles/documents_shared_with_me.py
Lines:
6 - 42
Complexity:
moderate

Purpose

This class serves as a utility for accessing and querying documents that have been shared with the currently authenticated user in SharePoint. It inherits from Entity and provides a static method to retrieve paginated, sorted list data of shared documents. The class is designed to work with SharePoint's UserProfiles service to fetch document sharing information.

Source Code

class DocumentsSharedWithMe(Entity):
    """Provides methods for working with a list that shares documents with the current user on the user's personal site.
    All methods in this object are static."""

    @staticmethod
    def get_list_data(context, sort_field_name, is_ascending_sort, offset, row_limit):
        """
        Gets the JSON string containing the row data for a list that shares documents with the current user on the
        user's personal site.
        :param office365.sharepoint.client_context.ClientContext context: Client context
        :param str sort_field_name: Specifies the view field on which to sort the data in the Web Part.
        :param bool is_ascending_sort: Specifies whether the data in the Web Part will be sorted in ascending order.
        :param int offset: Specifies the number of results to skip before displaying the data in the Web Part.
        :param int row_limit: Specifies the maximum number of items to be rendered in the Web Part at one time.
        """
        payload = {
            "sortFieldName": sort_field_name,
            "isAscendingSort": is_ascending_sort,
            "offset": offset,
            "rowLimit": row_limit,
        }
        return_type = ClientResult(context, str())
        qry = ServiceOperationQuery(
            DocumentsSharedWithMe(context),
            "GetListData",
            None,
            payload,
            None,
            return_type,
            True,
        )
        context.add_query(qry)
        return return_type

    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Portal.UserProfiles.DocumentsSharedWithMe"

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: An instance of ClientContext that provides the connection and authentication context for SharePoint operations. This is required for all service operations and must be properly initialized with site URL and credentials before use.

Return Value

The class constructor returns an instance of DocumentsSharedWithMe that inherits from Entity. The get_list_data static method returns a ClientResult object containing a string (JSON format) with the row data for documents shared with the current user. The entity_type_name property returns the fully qualified SharePoint entity type name as a string.

Class Interface

Methods

get_list_data(context: ClientContext, sort_field_name: str, is_ascending_sort: bool, offset: int, row_limit: int) -> ClientResult static

Purpose: Retrieves JSON string containing row data for documents shared with the current user, with support for sorting and pagination

Parameters:

  • context: ClientContext instance providing SharePoint connection and authentication
  • sort_field_name: Name of the view field to sort by (e.g., 'Modified', 'Title', 'Author')
  • is_ascending_sort: Boolean flag indicating sort direction - True for ascending, False for descending
  • offset: Number of results to skip before returning data, used for pagination (0-based)
  • row_limit: Maximum number of items to return in a single request

Returns: ClientResult object containing a string (JSON format) with the shared documents list data. Access the value after executing the query via result.value

entity_type_name() -> str property

Purpose: Returns the fully qualified SharePoint entity type name for this class

Returns: String 'Microsoft.SharePoint.Portal.UserProfiles.DocumentsSharedWithMe' representing the SharePoint entity type

Attributes

Name Type Description Scope
_entity_type_name str Internal storage for the SharePoint entity type name, accessed via the entity_type_name property instance

Dependencies

  • office365.runtime.client_result
  • office365.runtime.queries.service_operation
  • office365.sharepoint.entity

Required Imports

from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.entity import Entity

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.userprofiles.documents_shared_with_me import DocumentsSharedWithMe

# Initialize SharePoint context
ctx = ClientContext('https://tenant.sharepoint.com/sites/mysite').with_credentials(credentials)

# Get shared documents data (sorted by modified date, descending, first 50 items)
result = DocumentsSharedWithMe.get_list_data(
    context=ctx,
    sort_field_name='Modified',
    is_ascending_sort=False,
    offset=0,
    row_limit=50
)

# Execute the query
ctx.execute_query()

# Access the JSON string result
shared_docs_json = result.value
print(shared_docs_json)

Best Practices

  • Always ensure the ClientContext is properly authenticated before calling get_list_data
  • Call ctx.execute_query() after get_list_data to actually execute the service operation and populate the result
  • Use appropriate row_limit values to avoid performance issues with large result sets
  • Implement pagination using the offset parameter for large document collections
  • The get_list_data method is static, so it can be called without instantiating the class, though an instance is created internally for the query
  • Handle the JSON string result appropriately by parsing it before use
  • The entity_type_name property is used internally by the SharePoint framework and typically doesn't need to be called directly by users

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class DocumentsSharedWithGroup 85.1% similar

    A class representing a SharePoint list that manages documents shared with a SharePoint Group on a user's personal site.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/portal/userprofiles/documents_shared_with_group.py
  • class SharedWithMeItems 83.8% similar

    A SharePoint entity class that provides access to items shared with the current user, allowing retrieval of documents and files that others have shared.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/userprofiles/sharedwithme/items.py
  • class SharedWithMeItemCollection 79.6% similar

    A SharePoint entity collection class that provides static methods to retrieve items that have been shared with the current user, including both internal and external shared items.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/userprofiles/sharedwithme/item_collection.py
  • class SharedWithMeDocument 77.9% similar

    Represents a shared document in SharePoint with metadata about authors, editors, modification dates, and document properties.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/userprofiles/sharedwithme/document.py
  • class DocumentSharingManager 75.8% similar

    A SharePoint document sharing manager class that provides static methods for managing document permissions, sharing settings, and shared views in SharePoint.

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