Create a Formatted Date StringThis routine illustrates how to create a formatted date string that includes the day of the week, month, day, and year (e.g., Friday April 14, 2006). How It WorksThe formatted date is computed with a combination of the @Today , @Weekday , @Year , @Month , and @Day functions. The returned values are subsequently used to create the formatted date string, which is stored in the theDate variable. Implementation
To implement this solution, insert the following formula in an action button, column, or default value for a field. Optionally, replace
@Today
with a date or field. The
@Prompt
statement is used for
theDate := @Today;
theWeekday := @Select(@Weekday (theDate);
"Sunday"; "Monday";
"Tuesday"; "Wednesday";
"Thursday"; "Friday";
"Saturday"
);
theMonth := @Select(@Month(theDate);
"January"; "February"; "March";
"April"; "May"; "June";
"July"; "August"; "September";
"October"; "November"; "December"
);
theDay := @Text (@Day (@Today));
theYear := @Text (@Year (theDate));
result := "Today is " +
theWeekday + " " +
theMonth + " " +
theDay + ", " +
theYear;
@Prompt([Ok];"Result"; result);
Figure 14.5 depicts the result when implemented in an action button. Figure 14.5. Example of a formatted date string
|
Create an Attach File Button
Creating an Attach File button for an application provides the ability to insert files into the intended field. This routine prompts the
How It Works
When the button is clicked, the cursor
Note
You can also use Rich Text Lite, which by default will place a button
Implementation
To implement this technique, create a Rich Text field on a form and make note of the field name. Next, create an action button and
Figure 14.6. Hide property settings for an action button
Finally, insert the following formula in the Programmer's pane. Replace FIELDNAME with the name of a Rich Text field on the form.
@Command([EditGotoField]; "
FIELDNAME
");
@Command([EditInsertFileAttachment])
Note If the document is not in edit mode or there is no Rich Text field on the form, the error message shown in Figure 14.7 will most likely display. Figure 14.7. Error when attempting to attach a file to a document in read mode
|
Display the Windows File Finder DialogThe file finder dialog allows users to locate and select a workstation file. After a file has been selected, you can attach the file to a field, store the file location, or use the value in a formula. Figure 14.8 depicts the file finder dialog. Figure 14.8. Example of the Windows file finder dialog
How It Works
The
@Prompt
command includes a
LocalBrowse
parameter that displays the Windows file finder dialog. The fully qualified
ImplementationTo implement this solution, create a field on a form. Next, create a button on the form and insert the following formula, making sure to replace FIELDNAME with the actual name of the field on the form.
FIELD FIELDNAME := @Prompt([LocalBrowse];"Select a file";""); @Prompt([Ok];"Selected file"; FIELDNAME ) |

Mastering XPages: A Step-by-Step Guide to XPages Application Development and the XSP Language

XPages Extension Library: A Step-by-Step Guide to the Next Generation of XPages Components

Survival Guide for Lotus Notes and Domino Administrators

IBM Lotus Domino: Classic Web Application Development Techniques