Show/Hide Toolbars

Therefore Programming Interface 3.0

The following example shows how to replace the Therforeâ„¢ Workflow Form by a custom Workflow Form. In the example we display a custom workflow form for the Workflow Process "My Custom Process" and for every instance that is in "My Custom Task" step.

 

 

Requirements and Assumptions:

bullet AddIn project configured and registered as described in "AddIn Creation in C#" or "Add In Creation in VB .NET".

bullet A Workflow Process "My custom Process" with a manual Task "My Custom Task" is defined.

bullet A Windows Form "CustomWorkflowForm" is also created in this Add-In Project.

 

Visual Basic

Imports System.Runtime.InteropServices

Imports System.IO

Imports System.Windows.Forms

Imports Therefore.API

 

<Guid("02F95848-1E91-4061-AF7D-EC5727A86611), ComVisible(True), ClassInterface(ClassInterfaceType.None)> _

Public Class CustomWorkflowDialog 

    Implements ITheAddIn

 

     Public Sub GetHandledEvents(ByVal clientType As TheClientType, ByVal eventSet As TheEventSet) Implements ITheAddIn.GetHandledEvents

        eventSet.Add(TheEventType.OpenWorkflowInstance)

     End Sub

 

    Public Function HandleEvent(ByVal e As TheEvent) As Integer Implements ITheAddIn.HandleEvent public int HandleEvent(TheEvent pEvent)

    

        Dim nInstanceNo As Integer = pEvent.ObjectID

 

        Dim s As New TheServer

        s.Connect(TheClientType.CustomApplication)

 

        Dim wfInst As New TheWFInstance

        wfInst.Load(snInstanceNo)

 

        If (wfInst.ProcessName == "My Custom Process" && wfInst.CurrTaskName == "My Custom Task")

            Dim nDocNo As Integer = wfInst.GetLinkedDocAt(0).DocNo

 

            //create and show you customized workflow dialog

            Dim f As New CustomWorkflowForm(nDocNo)

            If (f.ShowDialog() == DialogResult.Cancel)

                Return 2 //return "user canceled request"

            Else If (f.ShowDialog() == DialogResult.OK)

                If (f.bApproved)

                    Dim wfTask As TheWFTask = wfInst.GetNextTaskAt(0)

                    wfInst.ClaimInstance(s)

                    wfInst.FinishCurrentTask(swfTask.TaskNo"")

                    Return 1 //return "instance was processed - refresh inbox"

                Else

                    Dim wfTask As TheWFTask = wfInst.GetNextTaskAt(0)

                    wfInst.ClaimInstance(s)

                    wfInst.FinishCurrentTask(swfTask.TaskNo"")

                    Return 1 //return "instance was processed - refresh inbox"

                End If

            End If

        End If

        Return 0 //return "display default workflow form"

    End Function

End Class

 

 

C#

using System;

using System.Collections.Generic;

using System.Text;

using Therefore.API;

using System.Windows.Forms;

using System.Runtime.InteropServices;

 

namespace Therefore.Addins

{

    [Guid("02F95848-1E91-4061-AF7D-EC5727A86611"), ComVisible(true)]

    public class CustomWorkflowDialog : ITheAddIn

    {

        #region ITheAddIn Members

 

        public void GetHandledEvents(TheClientType nClient,TheEventSet pEventSet)

        {

            pEventSet.Add(TheEventType.OpenWorkflowInstance);

        }

 

        public int HandleEvent(TheEvent pEvent)

        {

            int nInstanceNo = pEvent.ObjectID;

 

            TheServer s = new TheServer();

            s.Connect(TheClientType.CustomApplication);

 

            TheWFInstance wfInst = new TheWFInstance();

            wfInst.Load(snInstanceNo);

 

            if (wfInst.ProcessName == "My Custom Process" && wfInst.CurrTaskName == "My Custom Task")

            {

                int nDocNo = wfInst.GetLinkedDocAt(0).DocNo;

 

                //create and show you customized workflow dialog

                CustomWorkflowForm f = new CustomWorkflowForm(nDocNo);

                if (f.ShowDialog() == DialogResult.Cancel)

                    return 2;  //return "user canceled request"

                else if (f.ShowDialog() == DialogResult.OK)

                {

                    if (f.bApproved)

                    {

                        TheWFTask wfTask = wfInst.GetNextTaskAt(0);

                        wfInst.ClaimInstance(s);

                        wfInst.FinishCurrentTask(swfTask.TaskNo"");

                        return 1;   //return "instance was processed - refresh inbox"

                    }

                    else

                    {

                        TheWFTask wfTask = wfInst.GetNextTaskAt(1);

                        wfInst.ClaimInstance(s);

                        wfInst.FinishCurrentTask(swfTask.TaskNo"");

                        return 1;  //return "instance was processed - refresh inbox"

                    }

                }

            }

            return 0;   //return "display default workflow form"

        }

 

        #endregion

    }

}

 

See Also

OpenWorkflowInstance Event

 

© 2023 Therefore Corporation, all rights reserved.