Examples: FieldSetText method

  1. This script sets the value of the Creator field to the user's name after a document is opened in Edit mode. For example, if Brian Flokka creates a new document, the string "Brian Flokka" is placed in the Creator field.
    Sub Postopen(Source As Notesuidocument)
      Dim session As New NotesSession
      If source.EditMode Then
        Call source.FieldSetText _
        ( "Creator", session.CommonUserName )
      End If
    End Sub
  2. This script gets the value of four number fields: Q1, Q2, Q3, and Q4. It then converts them to integers using Cint(). It adds the four values together and sets the value of the Total field, using Cstr() to convert the result to a string.
    Sub Querysave(Source As Notesuidocument, Continue As Variant)
      a% = Cint( source.FieldGetText( "Q1" ) )
      b% = Cint( source.FieldGetText( "Q2" ) )
      c% = Cint( source.FieldGetText( "Q3" ) )
      d% = Cint( source.FieldGetText( "Q4" ) )
      Call source.FieldSetText _
      ( "Total", Cstr( a% + b% + c% + d% ) )
    End Sub