Simulating dynamic fields and labels

Often, one must dynamically create labels and fields on the Notes client. This code simulates dynamic fields and labels creation on the Notes Client.

Often, one is faced with a situation in which they need to dynamically create labels and fields on the Notes client -- but there is no easy way to do this. The code in this tip simulates dynamic fields and label creation on the Notes client using a combination of HTML, JavaScript and Formula. This is a basic example of how to work around this issue. There is ample scope for enhancement.

This takes two, computed-for-display, multi-value fields whose values create the text and the dropdown options for the dynamically generated labels and drop-down fields. Since the dynamic fields are not really saved on the Notes client, an onSubmit JavaScript populates a hidden field with the field labels and values, so the field labels and data are stored and can be reused (maybe displayed in another form by dynamically generating HTML).

Form: DynamicFields

Set the property - Render Passthru HTML in Notes. Then create two 'Computed for Display multivalue text fields.

1. LabelValues: All Labels that need to created. (could be a lookup from a view). Sample value: "Label1":"Label2":"Label3."
2. DataValues: All option Values that need to be present on the dropdown lists. These need to be concatenated with the labelvalues to identify them.

Sample Values:

Create a Computed Text. Make this as passthru HTML and add the formula behind this as:

<<Begin Computed 
Text Formula>>
tableRowPrefix := "<TR>
<TD Width=50>";
tableCellFix := "</TD><TD>";
tableRowSuffix := 

tableConstruct := "<TABLE>";

tmpLabelValue := "";
tmpDataValue :="";
n := 1;

@While(n <= @Elements(LabelValues);
tmpLabelValue := LabelValues[n];
tableConstruct := tableConstruct +
 tableRowPrefix + tmpLabelValue;
tmpDataValue :="";
tableConstruct := tableConstruct + 
tableCellFix + "<Select Name=""+

@While(m <=
tmpDataValue :=@Right(DataValues
tableConstruct := tableConstruct +
 "<OPTION>" + tmpDataValue + 
tmpDataValue :="";
tmpLabelValue := "";
tableConstruct := tableConstruct
+ tableRowSuffix;
n := n + 1);

tableConstruct := tableConstruct+

<<End Computed Text 

This creates the dropdown "pseudo-fields" and dynamic table.

Next create an editable text field called "totalValue". This stores the labels and values of the "pseudo-fields" upon saving.

Add an onSubmit 
JavaScript as below
//Begin writing values to the 
stored field.
thisdoc = document.forms[0];
thisdoc.totalValue.value = "";
thisField = thisdoc.elements[i]
thisdoc.totalValue.value = 
thisdoc.totalValue.value + "(" + + " - " +
selectedIndex].text + ")"
//end of Javascript onSubmit code

Next, to create a submit button for saving and closing the doc you can use:


Now when you submit the document the dynamically created fields are not saved, but their labels and values are inside the totalValue field as: "(Label1 - Data2)(Label2 - Data3)(Label3 - Data3)."

Possibly, you could even have the individual fields created with onUnload event by setting the field values, or even create a computed field with the appropriate HTML to display these values when the document is next opened. As programmers sometimes say, "We can do anything as long as we have the data!"

Hope you like this!

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Sandeep Goyal. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was last published in August 2004

Dig Deeper on HTML for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...