Examples: actions

Simulate Notes® menus for Web users

About this task

Web users don't have access to Notes® menu choices when they work in Domino® databases. Therefore, you should create menu equivalents for them.

Create actions with @command formulas and make them available as buttons in the action bar. Keep in mind that Domino® cannot translate commands based on a selected document in a view because there is no notion of a "selected" document on the Web. For actions such as "Create Response Document," you must add a form action to the Main Topic form for opening a Response document.

To Web-enable all buttons in a database as well as certain @commands, select the database property "Web access: Use JavaScript when generating pages." Without this property set, Domino® recognizes only the first button in a document and treats it by default as a Submit button that closes and saves the document.

Be aware that Domino® displays all buttons, actions, and hotspots -- even those that contain @commands and @functions that aren't supported for Web applications.

Complete these steps to create a button to open a new Main Topic in the current database:

Procedure

  1. Open the view where you want to add the button for Web users.
  2. Choose Create - Action - Action.
  3. Complete the Action Properties box. On the Action Info tab, do the following:
    • Enter the name "Create Main Topic."
    • Select "Include action in button bar."
    • Select "Notes® graphic" and select a graphic for the button.
  4. In the Info List, click Objects and click Create Main Topic.
  5. In the Run pull-down list, select Client and then Formula.
  6. Enter this formula:
    @Command([Compose];"Main Topic")
  7. Save the view.

Results

Examples of other commonly used menu items:

  • Create a document
    @Command([Compose]; "formname")
    @Command([Compose];"":"database"; "formname")
  • Open a view
    @Command([OpenView]; "viewname")
    @Command([OpenView];"":"database"; "viewname") 
    @Command([OpenView];"By Date")
  • Delete an open document
    @Command([Clear])
  • Close an open document or view
    @Command([CloseWindow])

Sending a document to reviewers

About this task

You want to simplify the process of distributing proposed concert schedules to a review board.

Procedure

  1. In the Concert Schedule form, create a field of type Names that will specify all the reviewers.
  2. In the Concert Schedule form, choose Create - Action - Action and specify the following in the Action Properties box:
    • Name -- Enter "Distribute for Review."
    • Display -- Select "Include action in button bar"; deselect "Include action in Action menu."
    • Button Graphic -- Select Notes® graphic and pick a graphic from the pull-down list.
  3. In the Info List, click Objects and select "Distribute for Review (Action)."
  4. In the Run pull-down list, select Client and then "Simple action(s)."
  5. Select the Add Action and Send Document actions.
  6. Save the form.

Approving and denying requests

About this task

You want to improve a Requisition form to make it easy for managers to approve or deny requests that are mailed to them. You create two form actions: "Approve Request" and "Deny Request."

The "Approve Request" action uses this formula to change the document's status to Approved and routes the document to the next approver:

FIELD Status:="Approved";
@MailSend(NextApprover;"";"";"For your review";"Click Approve Request to approve this requisition or click Deny Request to return the request to " + Initiator;"Initiator":"Body";[sign]);

The "Deny Request" action changes the document's status to Denied and routes a notification to the initiator.

FIELD Status:="Denied";
@MailSend(Initiator;"";"";"Re: Your request";"Your request was unable to be approved. Contact " + PreviousApprover + "for more information.");

Displaying hidden text with a checkbox action

About this task

This example would allow a user to check a box requesting the display of additional explanatory text for a data entry form. You can use a checkbox action anywhere you would use a regular action. When you create a checkbox action, you need two pieces of code. One is a formula for the "Value" property of the checkbox action to specify under what conditions Notes® should display the checkmark. The other, the "Click" formula or script, toggles the checkbox value and does whatever else you need the action to do. You must have a place, such as a field on a profile document, or an environment variable, to store the checkbox state.

A checkbox "value" formula, like a hide formula, must return a True/False value. If True, the checkmark is displayed. In this example, the value formula displays a checkmark if a multi-valued field personal profile named "Options" contains the value "Verbose".

@GetProfileField("UserProfile"; "Options"; @UserName) = "Verbose"

The example code for the "Click" event inserts the value "Verbose" into the profile document field if it's not already there, or removes it if it is there.

_opts := @GetProfileField("UserProfile"; "Options"; @UserName);
@If(_opts = "Verbose";
	@SetProfileField("UserProfile"; "Options"; @Trim(@Replace(_opts; "Verbose"; "")); @UserName);
	@SetProfileField("UserProfile"; "Options"; @Trim(_opts : "Verbose"); @UserName)
);
REM {Redisplay the current form in the new mode.};
@If(@IsDocBeingEdited; @Command([ViewRefreshFields]); "")

The code preceding the REM statement changes the value of the toggle. In this example, the Verbose option makes the application's forms display extra static text, to help novice users enter data. Hide formulas on the form test the profile document field to decide whether to display the text. If the user is editing a document, this action refreshes the screen to display the previously hidden help text (or vice versa). The hide formula might look like:

!(@GetProfileField("UserProfile"; "Options"; @UserName) = "Verbose")

Tips

About this task

  • Since the option for the checkbox action is stored in a profile document, it applies to the entire application, not just to the document the user is editing at the time. In some cases, you may prefer to use an environment variable, such as @Environment and @SetEnvironment, or a field stored in a Notes® document, using @GetDocField, @SetDocField, or @DbLookup.
  • Use an environment variable when you want the user's selection to apply to all users and applications on the workstation.
  • Profile documents replicate, so the user's selection will follow them if they use a different workstation.
  • If you use @DbLookup in your action's checkbox "Value" formula, remember that @DbLookup caches its results by default, so you must use the NoCache option.