Manage Learn to apply best practices and optimize your operations.

Updating computed fields from the Web browser

Ever have a situation when you need to display a computed field to a Web user, and then have a button or action update the field and display the new value? Problem is computed fields in Domino are rendered as text and the displayed value can not be changed using JavaScript on the Web. (Checking "Generate HTML for all fields" in Form Properties allows you to update the value from JavaScript, but you still can't change the displayed text.) Here's a handy work-around:

Code: Say you have a computed field called [TotalAmount], that you wish to display and update from a button or action in the browser. Insert the following pass-through HTML text around the computed field:
<INPUT NAME = "TotalAmount" VALUE = "[TotalAmount]" "READONLY">
where everything is text except for the actual computed field which is represented as [TotalAmount]. Make sure you highlight the entire line and use the Text dropdown to mark it as Pass-Through HTML. Also make sure you do not check the "Generate HTML for all fields" on the Form Properties dialogue.

Now you can access and update the TotalAmount field using JavaScript. Note that JS variables are automatically converted to text by Domino, so you will need to coerce the data type to perform calculations. For example, a button might contain the following JavaScript code to increment the TotalAmount field:
document.forms[0].TotalAmount.value= parseInt(document.forms[0].TotalAmount.value) + 1;

The revised value of TotalAmount is passed back to notes and can also be accessed by a WebQuerySave routine.

Note - Since you cannot check the "Generate HTML for all fields" option, you can simulate this action in the browser for hidden fields> using pass-through HTML of the form:
<INPUT NAME = "MField" VALUE = "[MField]" TYPE= "hidden">

This is the code that Domino would generate for hidden fields if the the "Generate HTML for all fields" option were enabled.

Note - If your application is to be used by both Web browsers and (R4.6 or later) Notes clients, you may need to implement this as a Web-only form. To do this, copy your original Notes form and modify the copy for use by the Web client. The two versions of the form should have different names and the same alias and hidden from either Web users or Notes clients as appropriate. For example, if your original form is called "Invoice", rename it to "UserInvoice-Notes | Invoice" copy it and rename the copy as "User Invoice-Web | Invoice". From the Designer Forms view, right click on each form select Design Properties, and check the appropriate "Hide Design Element from" check box. Now you can make the appropriate changes on the Web-only form without affecting the Notes users.


Dig Deeper on Domino Resources - Part 7

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...