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:

%REM
 Returns the Status Description 
associated with the specified Status Code

 Logic:
  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
%END REM

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
(dStatus.statusDesc(0))
    Goto outOfLoop   
   End If
   
   'Fetch Next Document
   Set dStatus = vStatus.
GetNextDocument(dStatus)
  Wend
 End If
 
outOfLoop:
 getStatusDescription = strStatusDesc
 
 'Close the handles
 Set dStatus = Nothing
 Set vStatus = Nothing
 Exit Function
errorHandler:
 Call handleError
("getStatusDescription",Err,Error$,Erl) 
 getStatusDescription = ""
End Function

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

@DbLookup("":"NoCache";@ServerName:
@DbName;"vStatusMaster";
 
  ;"
statusDesc")
 

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.

MEMBER FEEDBACK TO THIS TIP

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

@DbLookup("":"NoCache";@ServerName
:@DbName;"vStatusMaster";

 
  ;"statusDesc")
 

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 SearchDomino.com 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.

This was first published in July 2005
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close