Manage Learn to apply best practices and optimize your operations.

Using roles to build send to fields

Using roles to build send to fields

This Content Component encountered an error

I wrote this code for use in a submit button, but it can be modified...the key thing that it does is parse the database ACL looking for users with the specified role. Those with the role are appended to the SendTo field of the uidocument. This is useful in a workflow app, where, for example, electrical submits to test...from electrical submit button, we need to find all with the test role for notification of section completion. By simply changing the "role" argument, the code will work in other similar sections as is necessary...i.e., if test then submits to quality, just pop the code into test submit button and change the role to "quality". This elimates the need to hard code lists of users with @MailSend. From this point, someone annointed as manager of the database can add and remove users from the accompnying mailing lists for the sections simply by adding and removing roles from their listing in the ACL....effectively passing control of all notifications to the ACL...a front end non-designer interface. Also, code is included for field validation, where more fields can obviously be added or removed from the validation tests as desired.

Sub Click(Source As Button)
     ' This code written by A. Young on 8/15/2001
' Parses ACL for role which determines who receives mail for this section
' Builds list and sends mail to the specified users
'Code is designed to be completely modular, the only change required being
the role that is being used

     Dim workspace As New NotesUIWorkspace
     Dim ns As New NotesSession
     Dim ndb As NotesDatabase
     Dim uidoc As notesuidocument
     Dim nacl As NotesACL
     Dim nacle As NotesACLEntry
     Dim maildoc As NotesDocument
     Dim rtitem As NotesRichTextItem
     Dim varACLRoles As Variant
     Dim intFlag As Integer
     Dim listTotal As Integer
     Dim failChecks As Integer
     Dim this As String
     Dim this1 As String
     Dim this2 As String
     Dim fieldCheck1 As String
     Dim fieldCheck2 As String
     Dim message As String

     Set uidoc = workspace.CurrentDocument
     Set ndb = ns.CurrentDatabase
     Set nacl = ndb.ACL
     Set nacle = nacl.GetFirstEntry

     fieldCheck1 = uidoc.FieldGetText("<fieldtocheck1")
     fieldCheck2 = uidoc.FieldGetText("<fieldtocheck2>")
     listTotal = 0
     failChecks = 0

     message = "Your form was not submitted for the following reasons:" +
Chr(10) + Chr(10)

     If fieldCheck1 = "" Then
          failChecks = 1
          message = message + "<Your error message here.>" + Chr(10)
     End If
     If fieldCheck2 = "" Then
          failChecks = 1
          message = message + "<Your error message here>" + Chr(10)
     End If
     If failChecks <> 0 Then
          Goto Finish
     End If

     Do While Not (nacle Is Nothing)
          Set naclEnter = nacl.GetEntry( nacle.Name )
          intFlag = naclEnter.IsRoleEnabled("<RoleNameToCheck>")
          If intFlag Then
               uidoc.EditMode = True
               this = Strright(nacle.Name, "CN=")
               this1 = Strleft(this,"O=")
               this2 = Strright(this,"/O=")
               Call uidoc.FieldAppendText("SendTo", this1 + this2)

               listTotal = listTotal + 1
          End If
          Set nacle = nacl.GetNextEntry(nacle)
     If listTotal <> 0 Then
          Set doc = New NotesDocument(ndb)
          doc.SendTo = uidoc.FieldGetText("SendTo")
          doc.Form = "Memo"
          doc.Subject = "<Notification of subject here>"
          membody = "<Text intro placed in top of email memo>" +
          Set rtitem = New NotesRichTextItem(doc, "Body")
          Set maildoc = uidoc.Document
          Call rtitem.AppendText(membody)
          Call rtitem.AppendDocLink(maildoc, "<Text next to link>")
          Call doc.Send( True, doc.SendTo )
          Msgbox "<Successfully submitted message>", 64, "Submit completed."

          Call uidoc.FieldSetText("SendTo"," ")
          Call uidoc.FieldSetText("Status", "Submitted")
          Call uidoc.Save
          Call uidoc.Close
     End If
     If listTotal = 0 Then
          Msgbox "Submit not accepted. There is no one with the
required role in this database.", 16, "This submit has failed."
     End If
     If failChecks <> 0 Then
          message = message + Chr(10) + "Please make the above changes
and press Submit again"
          Messagebox message, 0+16, "Your Form was NOT submitted."
     End If
End Sub
This was last published in August 2001

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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