Avaliable XForm groups

Hi,
When building cht apps with the cht core framework, we need to create some custom app forms and custom contact forms.
In these cht forms we use some predefined survey groups like “user”, “contact”, “parent”, some of this groups work in app forms but not in contact forms
I used to see in calculate default value things like PARENT, and the parent_id is automagically returned.
Is there somewhere documented which groups ara avaliable to be used in app forms and which ones in contact forms ?
If not, could you please show me where in the cht core source code we can obtain these groups and default values ?
In an app forms I’m able to get the contact contact by using a contact group into another contact group, and this works fine, but if I try to get the user’s contact by doing the same thing, put a contact group into the user group, I’m not able to get this contact
Instead of using some trial and error method it will be very helpful some documentation about avaliable groups.
Thank you

1 Like

Short answer is that we do not have any great comprehensive documentation on this (that I know of). But we should and this has bugged me for awhile. I have collected some information based on various investigation and debugging that I have done recently and added it to this issue. Hopefully that comment can be useful to you in the short-term and in the long term that issue can be addressed (by myself or someone else).

2 Likes

I used to see in calculate default value things like PARENT, and the parent_id is automagically returned. Is there somewhere documented which groups ara avaliable to be used in app forms and which ones in contact forms
This all depends on where you’re launching the form from

In an app forms I’m able to get the contact contact by using a contact group into another contact group, and this works fine,
If you launched from a place, then the first contact group is this place. If it’s a person the it will be the person

but if I try to get the user’s contact by doing the same thing, put a contact group into the user group, I’m not able to get this contact
I believe you can get the users info directly in the user group

1 Like

but if I try to get the user’s contact by doing the same thing, put a contact group into the user group, I’m not able to get this contact
I believe you can get the users info directly in the user group

yes user info that is in user doc is avaliable in the form, but there are some fields in the contact that is associated with the user that is not in user’s doc, I try to get this fields but I have not been able to get them
I have a user “yirifp” that is associated with the contact whose name is “emilie” in emilie’s doc I have a feild “cscom_area”:“Yirimadio”, I would want get this cscom_area value from an app form, do not know if that is possible

After looking at this again, I realized I had misspoke in my original comment. The data loaded into the user group is NOT the user’s contact doc. Instead it is the actual CouchDB doc for the user (e.g. org.couchdb.user:username). The good news is that the contact_id field from this doc contains the id for the user’s contact doc. You can use this with the db-object functionality to load the user’s contact data.

Here is an example form where I am loading the value from my_field on my user’s contact doc and displaying it in a note:

type name label::en appearance relevant
begin_group inputs NO_LABEL false()
begin_group user NO_LABEL
db:person contact_id User’s contact id db-object
hidden my_field My Field
end_group
end_group
note my_note My Field: ${my_field}

Basically what is happening here is that by using the db:person/db-object on inputs/user/contact_id I am able to load the user’s contact doc fields right into the inputs/user group.

2 Likes

@jkuester definitively this is the solution that i was looking for
Thank so much

1 Like

For future reference, I have added a new page to the CHT documentation that has the breakdown of data available on forms.

1 Like