How can we help you today?

How to include workflow into a form through script

Mi-Forms solutions commonly utilize workflow as one of many components on a form. Here I will show how to implement some simple workflow through the script editor in the Mi-Forms Designer.

Workflow is to be implemented using the AfterOpen and ServerQueueing method as shown here. This is a simple example where inspectors will open new form sessions and when they finish the session, it will be sent to an Approvers queue who will review the form, and once they finish the session it will be sent to a Managers queue. Finally, when a manager finishes the session, it goest to the finished queue on the Mi-Forms Server.

So the workflow is as follows..

Inspectors -> Approvers -> Managers -> Finished

<MiCode(FormScriptEventType.AfterOpen)> _
Public Sub Form_AfterOpen(ByVal e As AfterOpenEventArgs)
'person to open new form session will be an inspector so set hidden value to Inspectors
_hdCurrentQueue.Value = "Inspectors"
End Sub
<MiCode(FormScriptEventType.ServerQueuing)> _
Public Sub Form_ServerQueuing(ByVal e As ServerQueuingEventArgs)
If _hdCurrentQueue.Value = "Inspectors" Then
'currently in inspectors queue, now move session to approver queue
e.NewQueue = "Approvers"
e.NewQueueDetails = "Inspector has finished form, now move to approvers"
_hdCurrentQueue.Value = "Approvers"
Else If _hdCurrentQueue.Value = "Approvers" Then
e.NewQueue = "Managers"
e.NewQueueDetails = "Approver has finished with form, now move to Managers"
_hdCurrentQueue.Value = "Managers"
Else If _hdCurrentQueue.Value = "Managers" Then
'Do nothing as the session will automatically go to Finished if not directed else where.
End If
End Sub

Typically it is best practice to store the current Queue into a hidden control, like above, so the value can be accessed throughout all form methods. This allows for flexibility to hide, show, enable, or disable certain aspects of the form depending on what Queue the session is currently in.