Setting primary contacts

We have the following hierarchy: district → healt_facility → village → household → person. Everytime we edit a village, the primary contact status disappears from the original primary contact, who was created within the village_create form. And there seems to be no way to define a new primary contact or replace one once a village is created. Also notable is that the village_create form isn’t pre-filled with the previous values when we enter the form via “edit”. On household level this works on the other hand and all previous values are pre-selected in the form.

Does someone have an idea why this could be the case? How can we edit villages without loosing the primary contacts and how can we change the primary contact after village creation?

Hi @cht-user
Could you please add few more details so that we can understand the issue more clearly?

Would it be possible to add screenshots?

When you click edit, are you seeing empty fields? Also, just wanted to confirm this does not work in the form “village_create” form but you see the values are filled in other form i.e. “household_create”?

It seems as though your contact fields in the edit version of the form might not match up with the corresponding create form. This would mean that upon editing the place, the primary contact fields are not prepopulated, and therefore when the place edits are saved it wipes out the primary contact.

If you can’t resolve this directly, it would help to see the create and edit forms in question, or at least the structure of those key fields. Would you be able to post those at least in part here?

Hi @niraj

When we create a new village, we can create the primary contact here:

After that we click on “edit”:

And the form opens again, but nothing is pre-selected and when we update the village, primary contact property gets lost (e.g., the golden star disappears from the previously created contact):

But in the case of the household_create form, it works perfectly fine and all fields are pre-selected.

Hi @marc

We are currently using the same “village_create” form for both creation and edit, as this method seems to work fine with the “household_create” form one level below.

Here you can find the 3 forms: village_create, village_edit (not in use) and household_create: Forms

1 Like

I was able to dig in with @jkuester and we think we found some causes of your issue. Essentially when reusing the create form as the edit form as well, the way the create form sets the primary contact ends up wiping out the primary contact.

For example, if the setting the primary contact question is answered with “Skip”, you will erase your existing contact. if(selected(${create_new_person},'none'), "", ...
This logic can get tricky, so I’d suggest using the model of the create and edit forms in the default config. You’ll see that the edit form is simpler, and has a small group to display and edit the existing primary contact:

As an aside, your forms seem to use some custom hierarchy with contact_type set to ccw. Displaying these contacts as expected within profiles, searches, or the person selector fields will depend on your configurable hierarchy, which we could not investigate without the full config.

Hope this helps to set you in the right direction, and let us know how it goes!

4 Likes

Thank you so much for your help @marc and @jkuester !

We’ve tried to implement our village creation process with the default config and edited the PLACE-TYPE-create and PLACE-TYPE-edit forms according to our needs. Now we can successfully edit a village with the edit form without loosing the primary contact.
The only thing that does not work yet as desired is the setting of the primary contact in the edit form (see screenshots):


The existing VHWs never appear in the search field (however, sometimes contacts from lower hierarchy levels appear , e.g. household level):

Do you guys know how the primary contact search field could be configured to show contacts on village-level and of type ccw?

1 Like

Do you guys know how the primary contact search field could be configured to show contacts on village-level and of type ccw?

Based on what you had in your original form, the type for your select_person field is set to db:person which means that you will only be able to select contacts with the person type. The db:person/db-object configuration is actually the deprecated old-style of contact selector. If you are on CHT 3.9+, you should switch to the new contact selector. Then you can specify the contact type(s) to search for (e.g. select-contact type-ccw). (Of course, you will only be able to select contacts that are visible to the current user. So, if you cannot see the contact on the “People” tab, you will not be able to find it in the seach.)

2 Likes

@jkuester This worked perfectly! Thank you very much for the help!

1 Like