- This JavaScript code shows an alert when activated by the onClick event of a button or action hotspot.
alert("This is the alert box.")
- This JavaScript code prompts the user for his or her name when activated by the onClick event of a button or action hotspot.
var message
var defaultanswer
message = "Please enter your name:";
defaultanswer = myForm.from.value;
result = prompt(message, defaultanswer);
if(result) {
myForm.results.value = result;
}
- This JavaScript example could be attached to the onClick event for a button or action hotspot. It determines how a mail message is delivered. For "bugs," the mail is directed to "SprManager." Other requests are directed to "WishListManager." The final line in this script launches mail.
var isBug = confirm("Are you reporting a bug?");
var recipient = isBug? "SprManager@xyz.com" : "WishListManager@xyz.com";
document.location = "mailto:" + recipient;
- This LotusScript button or action hotspot is useful in a mail message to a group of persons. When the recipient clicks the hotspot, the script sends a mail message indicating "Yes" or "No" for the "RSVP." For testing, the name of the current user is used -- in practice, you would use your name. Compare with the next example, which uses a formula solution.
'(Declarations)
Const MB_YESNO = 4
Const MB_ICONQUESTION = 32
Const IDYES = 6
'(Click event)
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
yesno = Messagebox _
("Do you want to attend?", MB_YESNO+MB_ICONQUESTION)
If yesno = IDYES Then rsvp = "Yes" Else rsvp = "No"
Call doc.AppendItemValue("Subject", "RSVP")
Call doc.AppendItemValue("Body", rsvp)
Call doc.Send(True, session.UserName)
End Sub
- This formula button or action hotspot is useful in a mail message to a group of persons. When the recipient clicks the hotspot, the formula sends a mail message indicating "Yes" or "No" for the "RSVP." For testing, the name of the current user is used -- in practice, you can use your name. Compare with the previous example, which uses a LotusScript solution.
yesno := @Prompt([YESNO]; "RSVP"; "Do you want to attend?");
rsvp := @If(yesno; "Yes"; "No");
@MailSend(@UserName; ""; ""; "RSVP"; ""; rsvp; "")
- This LotusScript button or action hotspot displays the sum of all OrderTotal fields in a database for one day. Each record in the database has OrderNumber, Date, and OrderTotal fields. The script finds all the documents in the database, then uses a loop and a comparison of dates to limit processing to today's documents. For each document, the script adds the OrderTotal to a dailyTotal variable.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Set db = session.CurrentDatabase
Set dc = db.AllDocuments
dailyTotal = 0
Set doc = dc.getFirstDocument
While Not(doc Is Nothing)
odate = doc.Date
dn = Datenumber(Year(odate(0)), _
Month(odate(0)), Day(odate(0)))
orderNumber = doc.OrderNumber
If dn = Today _
And orderNumber(0) <> "DAILY TOTAL" Then
orderTotal = doc.OrderTotal
dailyTotal = dailyTotal + orderTotal(0)
End If
Set doc = dc.getNextDocument(doc)
Wend
Messagebox Format(dailyTotal, "Currency")
End Sub
- This action hotspot is part of a navigator. The formula prompts the user and opens a view selected by the user.
view := @Prompt([OKCANCELLIST]; "Which view do you want to open?"; ""; ""; "By first name" : "By last name");
@Command([OpenView]; view)
- This formula shows "pop-up text from a formula." You can highlight as a hotspot the following text on a form: "Please note your user name and the current date and time." The formula associated with the hotspot would evaluate to a text string containing the necessary information.
"Your user name is " + @UserName + @NewLine + "The date and time are " + @Text(@Now)