Examples: Actions
- This LotusScript action prints the name of each Domino database in the Domino data directory on the computer running the script. The FirstDatabase and NextDatabase methods of NotesDbDirectory walk through all the databases for the specified server where null defaults to the current computer.
Sub Click(Source As Button) Dim directory As New NotesDbDirectory("") Dim db As NotesDatabase Set db = directory.GetFirstDatabase(DATABASE) While Not(db Is Nothing) Messagebox db.Title Set db = directory.GetNextDatabase() Wend Messagebox "The End" End Sub
- This formula lists the names in the Address Book on the CORP1 server, lets the user select any number of names, combines the selected names into a string using a comma and a space to separate names, and inserts the string into the current field. This action works best when the user is in the SendTo field of a mail database.
last := @Left(@DbColumn(""; "CORP1" : "NAMES.NSF"; "People"; 1); ","); first := @RightBack(@DbColumn(""; "CORP1" : "NAMES.NSF"; "People"; 2); " "); list := first + " " + last; name := @Prompt([OKCANCELLISTMULT]; "Send To"; "Who are you sending this memo to?"; ""; list); @Command([EditInsertText]; @Implode(name; ", "))
- This formula is a "Hide action if formula is true" formula. The action becomes available on the form menu or action bar only if the field OrderTotal is 100 or less. (If the user just entered a value for Order_Total in the current document, a document refresh must occur before the new value is effective.)
OrderTotal > 100
- These scripts collectively force the user to use an action to place an existing document in Edit mode. The action script places the current document in Edit mode. The Postopen and Querychangemode event scripts prevent the user from changing to Edit mode through other means such as Actions - Edit Document (CTRL+E).
'(Globals) object, (Declarations) event Dim allowEdit As Integer '(Form) object, Postopen event Sub Postopen(Source As Notesuidocument) 'Let document pass if new or not in EditMode 'Otherwise if existing document is in EditMode ' Set allowEdit so Querymodechange doesn't reprocess ' Turn EditMode off so document opens in Read mode ' Tell the user to use the action If source.EditMode And Not source.IsNewDoc Then allowEdit = True source.EditMode = False Messagebox _ "Use Edit mode action to edit document" Else allowEdit = False End If End Sub '(Form) object, Querymodechange event Sub Querymodechange(Source As Notesuidocument, Continue As Integer) 'Allow user to proceed, and turn off allowEdit if ' user clicked the action (allowEdit on) ' already processed by Postopen (allowEdit on) ' trying to get out of Edit mode ' (allowEdit off but EditMode on) 'Tell user to click action if changing existing document ' to Edit mode and not already processed by Postopen ' (allowEdit and EditMode off) If allowEdit Or (source.EditMode And Not allowEdit) Then allowEdit = False Else Messagebox _ "Use Edit mode action to edit document" continue = False End If End Sub '(Action) object, Click event Sub Click(Source As Button) Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument Set uidoc = workspace.CurrentDocument 'Turn on allowEdit so Querymodechange will let it pass 'Turn on EditMode allowEdit = True uidoc.EditMode = True End Sub