Effect of Widget Operations in Multi-Occurrence Lists

Using widget operations to address widgets in a multi-occurrence list can result in a discrepancy between the data displayed in the widget and the actual occurrences.

To understand the effect that using $widgetoperation can have with multiple occurrences, consider a form that displays 3 occurrences of an entity that contains two HTML widget fields.

  • For FLD1, Use Field Value is True.
  • For FLD2, Use Field Value is False.

The exec operation contains the following code:

operation exec
    numeric vCounter

  for vCounter = 1 to 10
    Callout 1 creocc "MYENT", vCounter 
    Callout 2 FLD1.MYENT = "This is occurrence no. %%$curocc(MYENT)%%%" 
    Callout 3 $fieldhandle("FLD2.MYENT")->$widgetoperation("loadHTML", "<html>%%FLD1.MYENT</html>")
end; exec
  1.  Create 10 occurrences of the entity.
  2.  For each occurrence, assign a value to FLD1 showing the current occurrence number .
  3.  For each occurrence, use the loadHTML widget operation to load the value of FLD1 into the FLD2 widget, without changing the value.

You might expect both fields to contain the same content, but this is not the case, as shown in the following illustration.

HTML Widget in Multiple Occurrences

FOrm with multiple occurrences of two HTML widgets

When the first three occurrences are created, the loadHTML widget operation is fired for the visible widgets and the HTML is loaded into the widgets as expected. Thereafter, as each new occurrence is created, it is bound to the third FLD2 widget and the new information is loaded into the widget.

When you scroll through these occurrences, the FLD1 widgets are correctly updated because their field value has changed. The field value of the FLD2 widgets has not changed, so they continue to display the same data.