TreeINFO-For-M365 documentation
    Preparing search index...

    Interface TypeDocHidden_IWorkflowService

    Service for managing workflow operations including starting workflows, retrieving workflow definitions, and handling workflow tasks.

    // Start a workflow on the current item
    const results = await tisa.workflow.start("ApprovalWorkflow");

    // Start a workflow with parameters
    const results = await tisa.workflow.start("ApprovalWorkflow", {
    approver: "john@contoso.com",
    priority: "High"
    });

    // Start a workflow with user-provided form data
    const results = await tisa.workflow.startWithForm("ApprovalWorkflow");
    interface TypeDocHidden_IWorkflowService {
        config: Config;
        instances: Instances;
        tasks: Tasks;
        start(workflowName: string, parameters?: Record<string, any>): Promise<StartInstanceResult[]>;
        startOnItems(
            workflowName: string,
            startOnItems: { itemId: number; listId: string }[],
            parameters?: Record<string, any>,
        ): Promise<StartInstanceResult[]>;
        startOnItemsWithForm(
            workflowName: string,
            startOnItems: { itemId: number; listId: string }[],
            parameters?: Record<string, any>,
            dialogConfig?: DialogConfig,
            onDialogButton?: OnDialogButtonClicked,
        ): Promise<StartInstanceResult[]>;
        startWithForm(
            workflowName: string,
            parameters?: Record<string, any>,
            dialogConfig?: DialogConfig,
            onDialogButton?: OnDialogButtonClicked,
        ): Promise<StartInstanceResult[]>;
    }

    Implemented by

    Index

    Properties

    config: Config

    Configuration service for managing workflow settings

    // Access workflow configuration service
    const workflowConfig = tisa.workflow.config;
    // Export a workflow configuration
    const exportedConfig = await workflowConfig.export("MyWorkflow");
    instances: Instances

    Service for managing workflow instances

    // Access workflow instances service
    const workflowInstances = tisa.workflow.instances;
    // Start a new workflow instance
    const startResults = await workflowInstances.start({
    workflow: "MyWorkflow",
    items: [{ listId: "list-guid", itemId: 1 }]
    });
    tasks: Tasks

    Service for managing workflow tasks

    // Access workflow tasks service
    const workflowTasks = tisa.workflow.tasks;
    // Get tasks assigned to the current user
    const myTasks = await workflowTasks.getMine();

    Methods

    • Starts a workflow on the current item or selected items without displaying a dialog. The workflow will be initiated with any provided parameters directly.

      Parameters

      • workflowName: string

        The internal name of the workflow to start

      • Optionalparameters: Record<string, any>

        Optional parameters to pass to the workflow instance

      Returns Promise<StartInstanceResult[]>

      Promise resolving to an array of workflow start responses indicating success or failure for each item

      Error if no list context is available or if the workflow start operation fails

      // Start a simple workflow without parameters
      const results = await tisa.workflow.start("SimpleWorkflow");
      // Results: [{ status: "Ok", instanceId: "guid-123", itemId: 1, error: null }]
      // Start a workflow with custom parameters
      const results = await tisa.workflow.start("ApprovalWorkflow", {
      approverEmail: "approver@contoso.com",
      priority: "High",
      dueDate: "2025-02-01"
      });
      // Results: [{ status: "Ok", instanceId: "guid-456", itemId: 1, error: null }]
      // Handle errors
      try {
      const results = await tisa.workflow.start("MyWorkflow");
      results.forEach(result => {
      if (result.status !== "Ok") {
      console.error(`Failed for item ${result.itemId}: ${result.error?.message}`);
      }
      });
      } catch (error) {
      console.error("Workflow start failed:", error.message);
      }
    • Starts a workflow on the specified items without displaying a dialog. The workflow will be initiated with any provided parameters directly.

      Parameters

      • workflowName: string

        The internal name of the workflow to start

      • startOnItems: { itemId: number; listId: string }[]

        Array of items (listId and itemId) on which to start the workflow

      • Optionalparameters: Record<string, any>

        Optional parameters to pass to the workflow instance

      Returns Promise<StartInstanceResult[]>

      Promise resolving to an array of workflow start responses indicating success or failure for each item

      Error if no list context is available or if the workflow start operation fails

      // Start a simple workflow without parameters
      const results = await tisa.workflow.start("SimpleWorkflow", [{ listId: "<guid>", itemId: 456 }]);
      // Results: [{ status: "Ok", instanceId: "guid-123", itemId: 1, error: null }]
      // Start a workflow with custom parameters
      const results = await tisa.workflow.start("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }], {
      approverEmail: "approver@contoso.com",
      priority: "High",
      dueDate: "2025-02-01"
      });
      // Results: [{ status: "Ok", instanceId: "guid-456", itemId: 1, error: null }]
      // Handle errors
      try {
      const results = await tisa.workflow.start("MyWorkflow", [{ listId: "<guid>", itemId: 456 }]);
      results.forEach(result => {
      if (result.status !== "Ok") {
      console.error(`Failed for item ${result.itemId}: ${result.error?.message}`);
      }
      });
      } catch (error) {
      console.error("Workflow start failed:", error.message);
      }
    • Starts a workflow on the specified items after collecting user input via a dialog form. The dialog is populated with workflow parameters defined in the workflow definition. User-provided form data is merged with optional additional parameters before workflow initiation.

      Parameters

      • workflowName: string

        The internal name of the workflow to start

      • startOnItems: { itemId: number; listId: string }[]

        Array of items (listId and itemId) on which to start the workflow

      • Optionalparameters: Record<string, any>

        Optional additional parameters to merge with form data (parameters takes precedence)

      • OptionaldialogConfig: DialogConfig

        Optional custom dialog configuration for appearance and field definitions If not provided, dialog is auto-generated from workflow parameters

      • OptionalonDialogButton: OnDialogButtonClicked

        Optional callback function invoked when dialog buttons are clicked, useful for data validation and transformation

      Returns Promise<StartInstanceResult[]>

      Promise resolving to an array of workflow start responses, or empty array if user cancels the dialog

      Error if workflow definition cannot be retrieved or workflow start fails

      // Basic usage: start workflow with user-provided form data
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }]);
      // Opens dialog with default fields, user fills form, workflow starts
      // With additional parameters
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }], {
      source: "automated",
      priority: "High"
      });
      // Form data is merged with these parameters before workflow starts
      // With custom dialog configuration
      const customDialog: DialogConfig = {
      Title: "Custom Approval Form",
      Template: [
      { Title: "Approver Email", InternalName: "approverEmail", Type: "Text", IsRequired: true },
      { Title: "Comments", InternalName: "comments", Type: "Note" }
      ]
      };
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }], undefined, customDialog);
      // With form validation callback
      const onDialogButton: OnDialogButtonClicked = async (button, data) => {
      if (button === "submit" && !data.approverEmail) {
      // Validation failed, dialog stays open
      return false;
      }
      return true; // Allow dialog to close
      };
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }], undefined, undefined, onDialogButton);
      // Handle dialog cancellation
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", [{ listId: "<guid>", itemId: 456 }]);
      if (results.length === 0) {
      console.log("User cancelled the workflow dialog");
      } else {
      console.log(`Workflow started on ${results.length} item(s)`);
      }
    • Starts a workflow on the current item or selected items after collecting user input via a dialog form. The dialog is populated with workflow parameters defined in the workflow definition. User-provided form data is merged with optional additional parameters before workflow initiation.

      Parameters

      • workflowName: string

        The internal name of the workflow to start

      • Optionalparameters: Record<string, any>

        Optional additional parameters to merge with form data (parameters takes precedence)

      • OptionaldialogConfig: DialogConfig

        Optional custom dialog configuration for appearance and field definitions If not provided, dialog is auto-generated from workflow parameters

      • OptionalonDialogButton: OnDialogButtonClicked

        Optional callback function invoked when dialog buttons are clicked, useful for data validation and transformation

      Returns Promise<StartInstanceResult[]>

      Promise resolving to an array of workflow start responses, or empty array if user cancels the dialog

      Error if workflow definition cannot be retrieved or workflow start fails

      // Basic usage: start workflow with user-provided form data
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow");
      // Opens dialog with default fields, user fills form, workflow starts
      // With additional parameters
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", {
      source: "automated",
      priority: "High"
      });
      // Form data is merged with these parameters before workflow starts
      // With custom dialog configuration
      const customDialog: DialogConfig = {
      Title: "Custom Approval Form",
      Template: [
      { Title: "Approver Email", InternalName: "approverEmail", Type: "Text", IsRequired: true },
      { Title: "Comments", InternalName: "comments", Type: "Note" }
      ]
      };
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", undefined, customDialog);
      // With form validation callback
      const onDialogButton: OnDialogButtonClicked = async (button, data) => {
      if (button === "submit" && !data.approverEmail) {
      // Validation failed, dialog stays open
      return false;
      }
      return true; // Allow dialog to close
      };
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow", undefined, undefined, onDialogButton);
      // Handle dialog cancellation
      const results = await tisa.workflow.startWithForm("ApprovalWorkflow");
      if (results.length === 0) {
      console.log("User cancelled the workflow dialog");
      } else {
      console.log(`Workflow started on ${results.length} item(s)`);
      }