Is it possible that you can’t access a contact’s parent information within a app form after upgrading from CHT Core 3.X to 4.X? In our project such a parent variable suddenly remains empty just after the version upgrade.
An example of such a variable would the the following in the calculation column:
…/inputs/contact/parent/parent/_id
The short answer is “no” this should definitely not happen as a result of a 4.x
upgrade and to my knowledge no one has reported similar behavior.
All of the known differences in forms are documented in the Preparing for 4.x guide (but like I said, none of this seems like it would cause this issue.)
Couple of questions:
- Which 4.x version of the CHT did you upgrade too?
- Does data load into
inputs/contact
(e.g. inputs/contact/name
)? What about inputs/contact/parent
?
- Can you double-check the contact document in the database for the contact in context when you fill out the form? Does it have the expected data for:
{ "parent": { "parent": { "_id" } } }
?
@jkuester Thank you for the reply!
- Version 4.6.0
inputs/contact
works. inputs/contact/parent
doesn’t work.
- Yes, it contains this data in the database:
{ "parent": { "parent": { "_id" } } }
. However, only the _id of the parents. The actual variable of the parent in our case is different from “_id”. Could the missing of this indicate a problem?
The actual variable of the parent in our case is different from “_id”. Could the missing of this indicate a problem?
Yes! I expect that is why this is not working! Deep down in the logic for loading this contact data into the form, it is processing the parent
data by looking for _id
fields on the parent lineage for the contact document.
Under normal circumstances, the system should be responsible for populating the parent lineage for a new contact added via a contact
form. (either extrapolating from a UUID provided in the parent
field or by interpreting the PARENT
default placeholder value as happens in the default
contact forms. Though, when creating contacts in app
forms you do need to make sure to properly populate the entire parent lineage of the new contact.
If possible, I would highly recommend updating your config to standardize how the parent
lineage data is recorded on a contact. Deavating from the standard pattern here could cause unintended consequences (such as the issue we are discussing in this thread).
I do want to reiterate, though, that this is not something I would expect to be effected by upgrading to 4.x
(unless you are on an incredibly old version of 3.x
). Looking at the history of the hydration.js
file that I linked above, the logic should be basically the same back at least to 3.9.0
in 2021.
Lastly, one workaround (that will not fix any other potential issues, but might get the data you need loaded into the form) could be to just use a contact selector on your custom parent id field to manually load the data from the parent’s doc.
It would be helpful if you could provide a copy of the form (or a subset of the form that repros the issue) and an example contact doc. Then I can try to debug this more on my end. We have ran into some weird edge cases involving inputs
when there is a relevant
expression or trying to include questions in-line with the data loaded from the contact. You might have a look though these issues and see if any of them seem relevant:
@jkuester Thank you so much for the reply and sorry for the late response.
In the meantime we found a workaround for the problem.
However, with the following link you can find a subset of the respective form: Form
1 Like