| Workflow Customization | Scroll | 
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: 
 
 
 
 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(s, nInstanceNo) 
 Â 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(s, wfTask.TaskNo, "")  Return 1 //return "instance was processed - refresh inbox"  Else  Dim wfTask As TheWFTask = wfInst.GetNextTaskAt(0)  wfInst.ClaimInstance(s)  wfInst.FinishCurrentTask(s, wfTask.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(s, nInstanceNo); 
 Â 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(s, wfTask.TaskNo, "");  return 1; //return "instance was processed - refresh inbox"  }  else  {  TheWFTask wfTask = wfInst.GetNextTaskAt(1);  wfInst.ClaimInstance(s);  wfInst.FinishCurrentTask(s, wfTask.TaskNo, "");  return 1; //return "instance was processed - refresh inbox"  }  }  }  return 0; //return "display default workflow form"  } 
  #endregion  } } | 
| 
 | 
| See Also 
 |