Manage Learn to apply best practices and optimize your operations.

Use a view, not hardcore status values, with a workflow

This tip provides code for making a master view for a workflow. In doing so, a developer avoids having to update status in a design as well as in the workflow's documents.

View member feedback to this tip.

When working with a workflow, do not hardcode status values. Instead, use a view to maintain the status value pairs. The number of status is the benchmark for the workflow, and the workflow is bound to change over a period of time. Sometimes, due to some business processes, the status itself gets changed. In that case updating the status in the design as well the documents would a waste of time. So, making a master view for the same would be a better solution.

Make a Form named StatusMaster; make it hidden so only administrators could update the StatusMaster. Add two fields, statusCode and statusDesc. Now create a view, (StatusMaster|vStatusMaster) with two columns, statusCode and statusDesc. Make use of the StatusMaster form to create the status value pairs.

Now, whenever you need status description for a particular stage you can use the following code for the same:

 Returns the Status Description 
associated with the specified Status Code

  lookup the statusCode in the 
Status Master view
  get a handle of the document
  return the Status Description of the same
  if no document found, return blank

Public Function getStatusDescription
(strStatusCode As String) As String
 'Function to fetch the Status
 Description wrt Status Code
 On Error Goto errorHandler
 Dim vStatus As NotesView
 Dim dStatus As NotesDocument
 Dim strStatusDesc As String
 Set vStatus = gdb.GetView("vStatusMaster")
 If Not vStatus Is Nothing Then
  Set dStatus = vStatus.GetFirstDocument
  While Not dStatus Is Nothing
   If Cstr(dStatus.statusCode(0)) = 
strStatusCode Then
    strStatusDesc = Cstr
    Goto outOfLoop   
   End If
   'Fetch Next Document
   Set dStatus = vStatus.
 End If
 getStatusDescription = strStatusDesc
 'Close the handles
 Set dStatus = Nothing
 Set vStatus = Nothing
 Exit Function
 Call handleError
 getStatusDescription = ""
End Function

If you want to get the Status Description in Formula, use the following piece of code:


Also, in the agents or LotusScript wherever you need to update the status, update the statusCode instead. Keep a computed for display field on the form for vStatus (visibleStatus). You can make use of the above formula for this field.


Hi all. Please note that in the Lotus script function getStatusDescription , gdb is a global variable declared in the script library as follows:

Public gs as NotesSession
Public gdb as NotesDatabase

and is initialized with the current database as follows:

Set gs = New NotesSession
Set gdb = gs.CurrentDatabase

Also, in the formula given



The columnNumber would be usually 1. This number references to the column position in the vStatusMaster View for statusCode Column/Field.

—Sunil Vishwakarma, tip author

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Sunilkumar Vishwakarma. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...