cht-core
cht-core copied to clipboard
db-object-widget not re-triggered when field becomes relevant
Describe the bug
A select-contact
field can be pre-populated by setting its calculation
value to the Id of a contact to load. However, when the field is non-relevant, no data is loaded for the contact. Then, if the field does become relevant later, the db-object-widget code does not get triggered and so no data gets loaded.
To Reproduce
Use a select-contact
field in a group to load data for a pre-populated contact id. If the group is relevant when the form loads, then the data for the contact is loaded as expected. However, if the group is non-relevant when the form loads and then later becomes relevant, no data will be loaded for the contact (and the contact's name will not be shown in the question widget).
Expected behavior
When a select-contact
field becomes relevant, it should evaluate the db-object-widget logic when there is a pre-populated id value.
Environment
Happening on master
(4.4.1
+) and on 3.9.0
.
Additional context
Note that a non-relevant select-contact
field that becomes relevant behaves just fine when the value is selected by the user. It is just the case where the value is pre-populated that results in the logic not getting triggered.
This issue seems related to https://github.com/medic/cht-core/issues/8225, but is not exactly the same since it is not specific to inputs
.
Originally reported on the forum.
To reproduce this issue, use this form: lookup.xlsx
Change the calculation
column E27, to a contact ID so the db-object widget preselects that.
Remove the content from the relevant
column D43 (${hh_visit_outcome}='visit_success'
) to see the db-object preselecting the calculated value, and add that back to see how the relevant
affects the widget.
Removed the "affects" labels as the bug isn't a regression.