Display a custom message box using a LotusScript-generated button

Display a custom message box using a LotusScript-generated button

This LotusScript will display custom messages
More LotusScript resources:
Tutorial: 30 LotusScript tips

Our top 10 LotusScript tips

LotusScript Reference Center

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

after running code in the background for any Lotus Notes document/data processing, email, etc. The LotusScript code will also close the window automatically -- without requiring any additional clicks.

To display a customized message box, you first must create a button on any Lotus Notes form that will call another Messagebox or Dialogbox. Then write the following code in an on-click event.

Note: This code can also be used in an agent, if needed.


Sub Click(Source As Button)
 Dim session As New NotesSession
 Dim workspace As New NotesUIWorkspace 
 Dim db As NotesDatabase
 Dim tempdoc As Notesdocument
 Set db = session.currentdatabase
 Set tempDoc = db.CreateDocument
 Call workspace.DialogBox( "msgBoxCloseAuto",
 True, True, True, True, False, False, 
"MessageBox Closing",TempDoc, True,True ) 
End Sub

After writing the code, follow these steps:

  • Create another form called msgBoxCloseAuto.
  • Enable the option "Automatically refresh fields."
  • Create a button and place it in a table.
  • Write the message that you want to be displayed in the button text.
  • Write the following code on the Postrecalc event of the msgBoxCloseAuto form.

Sub Postrecalc(Source As Notesuidocument)
 Sleep 3
 source.close
End Sub

This will display the second form as a Messagebox or Dialogbox, depending on which you select, and will close automatically after three seconds.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Vinay Sharma. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was first published in August 2008

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.