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.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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:
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 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.