🔍 Code Extractor

class EmployeeEngagement

Maturity: 38

A SharePoint client class for interacting with Microsoft Viva Employee Engagement features, providing access to dashboard content, Viva Home configuration, and app settings.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/viva/employee_engagement.py
Lines:
10 - 47
Complexity:
moderate

Purpose

This class serves as a client-side representation of SharePoint's Employee Engagement service (SP.EmployeeEngagement). It enables developers to retrieve employee engagement dashboard content, access Viva Home configurations, and manage app settings through the SharePoint REST API. The class inherits from Entity and follows the Office365 SDK pattern for making service operation queries and function queries to SharePoint endpoints.

Source Code

class EmployeeEngagement(Entity):
    def __init__(self, context):
        super(EmployeeEngagement, self).__init__(
            context, ResourcePath("SP.EmployeeEngagement")
        )

    def dashboard_content(self, override_language_code=None):
        """
        :param str override_language_code:
        """
        return_type = ClientResult(self.context, str())
        payload = {"return return_type": override_language_code}
        qry = ServiceOperationQuery(
            self, "DashboardContent", None, payload, None, return_type
        )
        self.context.add_query(qry)
        return return_type

    def viva_home_configuration(self):
        return_type = ClientResult(self.context, {})
        qry = FunctionQuery(self, "VivaHomeConfiguration", None, return_type)
        self.context.add_query(qry)
        return return_type

    def viva_home(self):
        return_type = VivaHome(self.context)
        qry = ServiceOperationQuery(self, "VivaHome", return_type=return_type)
        self.context.add_query(qry)
        return return_type

    @property
    def app_configuration(self):
        return self.properties.get(
            "AppConfiguration",
            AppConfiguration(
                self.context, ResourcePath("AppConfiguration", self.resource_path)
            ),
        )

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: A client context object that manages the connection to SharePoint and handles query execution. This context is required for all API operations and is passed to parent Entity class and used throughout method calls to add queries and manage results.

Return Value

Instantiation returns an EmployeeEngagement object configured with the SharePoint resource path 'SP.EmployeeEngagement'. Methods return various types: dashboard_content() returns ClientResult containing a string, viva_home_configuration() returns ClientResult containing a dictionary, viva_home() returns a VivaHome object, and app_configuration property returns an AppConfiguration object.

Class Interface

Methods

__init__(self, context)

Purpose: Initializes the EmployeeEngagement instance with a client context and sets up the resource path for SharePoint API calls

Parameters:

  • context: Client context object for managing SharePoint connection and query execution

Returns: None (constructor)

dashboard_content(self, override_language_code=None) -> ClientResult

Purpose: Retrieves the employee engagement dashboard content, optionally in a specific language

Parameters:

  • override_language_code: Optional string specifying the language code (e.g., 'en-US', 'fr-FR') to override the default language for dashboard content

Returns: ClientResult object containing a string with the dashboard content. Access the value after executing the query.

viva_home_configuration(self) -> ClientResult

Purpose: Retrieves the Viva Home configuration settings as a dictionary

Returns: ClientResult object containing a dictionary with Viva Home configuration data. Access the value after executing the query.

viva_home(self) -> VivaHome

Purpose: Retrieves the VivaHome entity object for accessing Viva Home features and data

Returns: VivaHome object that can be used to interact with Viva Home features. Execute the query to populate the object.

app_configuration property

Purpose: Provides access to the AppConfiguration entity for managing app-level settings

Returns: AppConfiguration object retrieved from properties cache or newly created with appropriate resource path

Attributes

Name Type Description Scope
context ClientContext The client context object inherited from Entity that manages SharePoint connection and query execution instance
resource_path ResourcePath The resource path 'SP.EmployeeEngagement' used for constructing API endpoints, inherited from Entity instance
properties dict Dictionary storing cached entity properties including AppConfiguration, inherited from Entity instance

Dependencies

  • office365-runtime
  • office365-sharepoint

Required Imports

from office365.runtime.client_result import ClientResult
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.function import FunctionQuery
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.entity import Entity
from office365.sharepoint.viva.app_configuration import AppConfiguration
from office365.sharepoint.viva.home import VivaHome

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.viva.employee_engagement import EmployeeEngagement

# Authenticate and create context
ctx = ClientContext(site_url).with_credentials(credentials)

# Create EmployeeEngagement instance
engagement = EmployeeEngagement(ctx)

# Get dashboard content with default language
dashboard_result = engagement.dashboard_content()
ctx.execute_query()
print(dashboard_result.value)

# Get dashboard content with specific language
dashboard_fr = engagement.dashboard_content(override_language_code='fr-FR')
ctx.execute_query()
print(dashboard_fr.value)

# Get Viva Home configuration
config_result = engagement.viva_home_configuration()
ctx.execute_query()
print(config_result.value)

# Access Viva Home
viva_home = engagement.viva_home()
ctx.execute_query()

# Access app configuration
app_config = engagement.app_configuration
ctx.load(app_config)
ctx.execute_query()

Best Practices

  • Always call ctx.execute_query() after invoking methods to execute the queued operations and retrieve results
  • The context object must be properly authenticated before creating an EmployeeEngagement instance
  • Use override_language_code parameter in dashboard_content() to retrieve localized content for specific languages
  • Access ClientResult.value property only after executing the query to get the actual result data
  • The app_configuration property uses lazy loading - it will be fetched from the server when first accessed and cached in properties
  • Methods add queries to the context but don't execute them immediately - this allows batching multiple operations
  • Ensure proper error handling around execute_query() calls as network or permission issues may occur
  • The class follows the Office365 SDK pattern where methods return result containers that are populated after query execution

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class VivaHome 81.5% similar

    VivaHome is a SharePoint entity class representing a Microsoft Viva Home component, providing access to Viva Home functionality within SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/viva/home.py
  • class EmployeeExperienceController 70.7% similar

    EmployeeExperienceController is a SharePoint entity class that represents the Employee Experience controller in Office 365 SharePoint, inheriting from the base Entity class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/viva/employee_experience_controller.py
  • class VivaSiteManager 69.8% similar

    VivaSiteManager is a SharePoint entity class that manages Viva site-related operations within the Microsoft SharePoint Portal infrastructure.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/viva/site_manager.py
  • class EmployeeExperience 66.3% similar

    A container class that exposes navigation properties for employee experience resources, specifically providing access to learning providers in Microsoft 365.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/teams/viva/employee_experience.py
  • class EmployeeExperienceUser 61.8% similar

    EmployeeExperienceUser is a class representing a user entity in the Microsoft 365 Employee Experience context, inheriting from the Entity base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/teams/viva/employee_experience_user.py
← Back to Browse