Getting User Input

You can use several @Functions to get input from users, including @DialogBox() , @PickList() and @Prompt() . @Prompt has a number of variations, from a simple OK dialog box to a multivalue select box. The function @DialogBox() displays any form for user input, but it is most effective when used with a form or subform containing a layout region or a table. Using @DialogBox() in that fashion enables you to create what appear to be standard Windows dialog boxes. The @Picklist() function displays either a view or a Domino directory in a dialog box.

CAUTION

Each of the @Functions discussed in this section are available only to Notes clients . They will not function on the Web.

 

Using @Prompt

@Prompt has a number of useful styles. The syntax of @Prompt is as follows :

@Prompt([style] : [ NOSORT ] ; windowtitle ; promptText ; defaultChoice ; choiceList ;
graphics/ccc.gif
fileType )

Table 12.13 describes the styles for @Prompt .

Table 12.13. @Prompt Style

Style Result
[CHOOSEDATABASE] Displays an open database browse window
[LocalBrowse] Shows a pick list of files on the local hard drive
[OK] Displays a simple box with a message and a single OK button
[OkCancelCombo] Displays a list of choices in a drop-down box from which a single value can be selected
[OkCancelEdit] Presents an input box with OK and Cancel buttons
[OkCancelEditCombo] Displays a list of choices in a drop-down box from which a single value can be selected, and enables the user to type a new value
[OkCancelList] Displays a list of choices from which a single value can be selected
[OkCancelListMult] Displays a list of choices from which more than one value can be selected
[Password] Enables a user to securely type a password
[YesNo] Displays a box with two buttons, Yes and No
[YesNoCancel] Presents a box with three buttons, Yes, No, and Cancel

CAUTION

Be careful using @Prompt() , @DialogBox() , and @Picklist() in agents. Agents using the Formula language operate on one document at a time and do not store values from one document to the next . It is often good practice to restrict an agent using these @Functions to the setting Manually from an Agent List, which keeps the agent from appearing in the Action menu. You then launch the agent from a Form Action Bar button. If you enable the user to run the agent from the menu, he can potentially run it on multiple documents ”literally, hundreds and hundreds, or worse , all documents in the database. It would be extremely frustrating to the end user to answer @Prompt([OKCANCELEDIT]...) over and over again.

 

The following is an example of code from an agent that runs manually from the agent list and that is launched by an action button in a view. This example shows you how @Prompt() can be used to obtain user feedback and incorporate that feedback in a document:

REM "Find out how many hours it took"; 
jnHours := @Prompt([OKCANCELEDIT]; "Effort";
 "Please enter the number of hours."; 0);
@If(jnHours = 0; @Return(""); @Success);
FIELD nActual := jnHours;
FIELD cStatus := "Completed";
FIELD dComplete := @Today

Figure 12.10 shows the dialog box displayed by the agent using @Prompt .

Figure 12.10. The prompt box asking for the number of hours is displayed by @Prompt([OKCANCELEDIT...) .

graphics/12fig10.jpg

Using @DialogBox

@DialogBox() can be used with any form or subform to gather or display input. If the form or subform contains layout regions or tables, @DialogBox() will display the first layout region or table. Figure 12.11 shows the use of @DialogBox() with a subform containing a layout region. The layout region is set to 3D, which gives the dialog box a standard Windows look and feel. When the dialog box is opened, any fields on the form that have corresponding fields in the underlying document are inherited. Similarly, unless you specify otherwise , when you close the dialog box by clicking OK, the values you have entered in the dialog box are saved to the underlying document.

Figure 12.11. Using @DialogBox() to get user input is a powerful tool.

graphics/12fig11.jpg

For the values entered using @DialogBox , the underlying document must be in edit mode. @DialogBox has several parameters that you can use to determine whether it displays information, stores it in the document, or allows new fields to be written to the document. You can also specify a title for the window and the location of the buttons. The syntax of @DialogBox() is as follows:

@DialogBox( formname ; [AutoHorzFit] : [AutoVertFit] : [NoCancel] : 
[NoNewFields] : [NoFieldUpdate] : [ReadOnly] ; [SizeToTable] ;
[NoOkCancel] : [OkCancelAtBottom] ; windowtitle )

The parameters for @DialogBox are described in Table 12.14.

Table 12.14. @DialogBox Parameters

Parameter Result
formname Identifies the form or subform to be used in the dialog box.
[AutoHorzFit] Sizes the window horizontally to fit the first table or layout region.
[AutoVertFit] Sizes the window vertically to fit the first table or layout region.
[NoCancel] Suppresses the Cancel button, displaying only the OK button.
[NoNewFields] Keeps fields in the dialog box that do not exist in the document from being added to the document.
[NoFieldUpdate] Keeps edits in the dialog box from being added to the underlying document.
[ReadOnly] Disallows editing in the dialog box.
[SizeToTable] Uses the first table on the form, ignoring any layout regions.
[NoOKCancel] Suppresses display of the OK button, and stops any edits in the dialog box from updating the underlying document.
[OKCancelAtBottom] Places the buttons at the bottom of the dialog box instead of on the right side. (New to Designer 6.)
windowtitle Text entered displays in the dialog box window title bar. If this parameter is omitted, Lotus Notes appears in the title bar.

All parameters are optional except formname . If you are using a layout region, it is best to use both [AutoHorzFit] and [AutoVertFit] parameters. The following formula for an action button launches an edit window into a sales document:

@DialogBox("subDBoxSales";[AutoHorzFit]:[AutoVertFit]:[OkCancelAtBottom]; "Sales Dialog
graphics/ccc.gif
Box Example")

TIP

If you looked at the last formula, you might have seen the title of the dialog box source, subDialogSales. You don't have to create a full-blown form for @DialogBox . You can create a layout region on a subform and call it in the same way you call a form. Consider adding a prefix such as dBox or subDBox to the form or subform name to distinguish it from other forms or subforms. For example, dBoxHistory could be used for a subform used to display document history.

 

Using @PickList()

The function @PickList() loads displays either a view or a lookup into the Domino directory in a dialog box with OK and Cancel buttons. It is extremely fast and does not cache the results. The syntax is as follows:

@PickList([CUSTOM]:[SINGLE]; server:file; viewName; windowTitle; promptText; columnNumber;
graphics/ccc.gif
category)

Table 12.15 describes the pick list styles available. Figure 12.12 shows an example. The following is the code that produced the pick list:

@PickList([Custom] ; ""; "PL"; "Parts List"; "Choose a part"; 1);

Figure 12.12. @PickList produces a dialog box using a view. A check mark indicates which document(s) have been selected.

graphics/12fig12.jpg

Table 12.15. @PickList Styles

Style Result
[CUSTOM] Used when displaying views
[NAME] , [SINGLE] Displays a Domino directory pick list selecting single or multiple names
[ROOM] Selects a room from a Domino directory
[RESOURCE] Selects a resource from a Domino directory
[FOLDERS] Along with multiple keywords, displays a pick list of folders for single or multiple selections

R5 added the capability to use a replica ID in @PickList() . This removed a serious limitation in that, before R5, you had to know the filename and path relative to the data directory to call @PickList() .

@Picklist() can also display a lookup into the Domino directory. The following is the syntax for that lookup:

@PickList([Name] : [Single])

If you specify Single , Notes displays a list from the Domino directory that enables you to choose a single name. Otherwise, you get the familiar two-pane mover dialog box that enables the user to select multiple entries from the Domino directory.

Part I. Introduction to Release 6

Whats New in Release 6?

The Release 6 Object Store

The Integrated Development Environment

Part II. Foundations of Application Design

Forms Design

Advanced Form Design

Designing Views

Using Shared Resources in Domino Applications

Using the Page Designer

Creating Outlines

Adding Framesets to Domino Applications

Automating Your Application with Agents

Part III. Programming Domino Applications

Using the Formula Language

Real-World Examples Using the Formula Language

Writing LotusScript for Domino Applications

Real-World LotusScript Examples

Writing JavaScript for Domino Applications

Real-World JavaScript Examples

Writing Java for Domino Applications

Real-World Java Examples

Enhancing Domino Applications for the Web

Part IV. Advanced Design Topics

Accessing Data with XML

Accessing Data with DECS and DCRs

Security and Domino Applications

Creating Workflow Applications

Analyzing Domino Applications

Part V. Appendices

Appendix A. HTML Reference

Appendix B. Domino URL Reference



Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net