| Using Front-end or Back-end Lotusscript to Cycle String Arrays 
 Background:
 Because of the possibility of multi-value fields, when you access a field through the backend, it is looked at as an array because it can more than one value.  Even though a field may not be defined as multi-value, script still wants the (0) for the first element of the array.  What is interesting, though, is that if you have a multi-value defined field you can set a variable equal to it, var = doc.multiValueField (notice no (0)) and it will automatically create the variable as an array with all the values.  Then, you can use Ubound, etc. to get the number elements and ForAlls to step through the array.
 
 Credit:
 Arlene Rafferty
 
 
 Front-end and Back-end Solutions:
 
 Front-end simple example which returns all the values as one string separated by semi-colons
 Dim uiDoc as NotesUIDocument		' current front-end doc open
 Dim fldValsStr as String			' array of field data concatenated as a string value by the UI call FieldGetText
 Dim fldVals as Variant				' array of field value as strings
 
 Set uiDoc = w.CurrentUIDocument
 ...
 fldValsStr  = uiDoc.FieldGetText("MailNames")
 messagebox fldValsStr
 ...
 ' if I want all the MailNames as an array of strings
 fldVals = Split(fldValsStr, ";")
 
 
 Back-end simple example:
 Dim uiDoc as NotesUIDocument		' current front-end doc open
 Dim doc as NotesDocument			' current doc
 Dim fldVals as Variant				' array of field value type (e.g. strings, dates, or whatever the field data type is)
 
 Set uiDoc = w.CurrentUIDocument
 Set doc = uiDoc.Document 			' works if saved
 fldVals = doc.GetItemValue( "MailNames")
 If (fldVals is Nothing) Then
 Exit Sub
 Else
 Forall fldVal in fldVals
 Messagebox Cstr(fldVal)
 End Forall
 End If
 
 
 Short Syntax example:
 Dim doc as NotesDocument			' current doc
 Dim MailNames As Variant			' subject of current doc as field values/variant
 MailNames = doc.MailNames
 Messagebox( MailNames( 0 ) )
 
 This works unless a new version of Notes/Domino turns that field into a standard function.
 This happened to us with using "Lock". We were doing custom document locking that broke when document.Lock() and document.UnLock().
 Dim doc as NotesDocument			' current doc
 Dim Lock As Variant				' lock field to prohibit document from being edited. Lock = "1" prohibit go to edit mode. Lock ="0", allow convert to edit mode
 Lock = doc.Lock
 ' or to set
 doc.Lock = "1"
 
 
 previous page
 
 
 |