class WorkflowTemplate
A class representing a workflow template that is currently deployed on a SharePoint site, inheriting from the Entity base class.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/workflow/template.py
4 - 5
simple
Purpose
This class serves as a data model for workflow templates in SharePoint Online. It represents workflow templates that are deployed and available on a SharePoint site, providing an object-oriented interface to interact with SharePoint workflow template entities. As it inherits from Entity, it likely provides methods for CRUD operations and property access for workflow template metadata.
Source Code
class WorkflowTemplate(Entity):
"""Represents a workflow template currently deployed on the site"""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
bases: Inherits from Entity class, which provides base functionality for SharePoint entities including property management, REST API communication, and entity lifecycle operations
Return Value
Instantiation returns a WorkflowTemplate object that represents a SharePoint workflow template entity. The object provides access to workflow template properties and methods inherited from the Entity base class for interacting with the SharePoint REST API.
Class Interface
Dependencies
office365-rest-python-client
Required Imports
from office365.sharepoint.workflow.workflow_template import WorkflowTemplate
from office365.sharepoint.entity import Entity
Usage Example
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.workflow.workflow_template import WorkflowTemplate
# Authenticate to SharePoint
ctx = ClientContext(site_url).with_credentials(credentials)
# Get workflow templates from the site
workflow_templates = ctx.web.workflow_templates
ctx.load(workflow_templates)
ctx.execute_query()
# Iterate through templates
for template in workflow_templates:
print(f"Template Name: {template.properties.get('Name', 'N/A')}")
print(f"Template ID: {template.properties.get('Id', 'N/A')}")
# Access a specific workflow template
if len(workflow_templates) > 0:
template = workflow_templates[0]
ctx.load(template)
ctx.execute_query()
# Access template properties
template_name = template.properties.get('Name')
Best Practices
- Always load the WorkflowTemplate object using ctx.load() before accessing its properties to ensure data is fetched from SharePoint
- Call ctx.execute_query() after load operations to execute the pending requests against SharePoint
- Handle authentication properly before attempting to access workflow templates
- Check for appropriate permissions as workflow template access may require specific SharePoint permissions
- Use the properties dictionary to access workflow template metadata as the specific properties are inherited from Entity
- Consider caching workflow template data if accessed frequently to reduce API calls
- The class is primarily a data container and relies on the Entity base class for most functionality
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class WorkflowInstance 76.4% similar
-
class WorkflowAssociation 74.6% similar
-
class WebTemplateCollection 70.8% similar
-
class WebTemplate 69.9% similar
-
class SPOTenantWebTemplateCollection 67.6% similar