Consider the following hierarchy structure:
NPO
Team Area
Indawo
Dwelling
Household
Household member
Is it possible to access the project property of the NPO on both the household and household member items without using a data duplication approach, or moving the question to a lower level?
The use case is that we only want to show certain app forms if the NPO has agreed to participate on that project. Those forms should then become a required task to complete on households and household members.
The requirement must be satisfied when logging in as a chw which is a direct child of the indawo level - thus visually we only see from Indawo down.
Thank you for getting back to me regarding this.
We opted to move the projects value to the Indawo level for the intirim.
With regards to showing/hiding app forms based on this property.
Is it possible to do so in the <app_form_name>.properties.json file in the expression string?
And if so, could you please provide an example?
At the moment I only have access to the contact the app form is actioned on, not the parent.parent of that contact.
Eg: "expression": "contact.contact_type === 'hhm'"
Edit: @jkuester I don’t know if you perhaps have any thoughts on this?
The properties that you have access to in the form properties expression are:
contact - the contact document
user - the contact document that the logged in user is associated with
summary - the result of evaluating your contact summary script, when passed the contact.
The contact summary script will receive parents for a given contact (through the lineage property) if they are available on the local device. Can you try leveraging that?
Thank you for getting back to me regarding this and providing an explanation of the available properties.
That’s true, we currently use the contact and lineage in order to display various properties!
So the parent we’re interested in would be lineage[2] as from the bottom up it would be household -> dwelling -> indawo.
The full property reference being lineage[2].contact.project if I’m understanding correctly.
Though I am a tad bit unsure how to return this value we’re interested in.
Is it as simple as setting a variable equals to the reference mentioned above and then simply returning it in the module.exports = {...}, and then finally referencing it for consumption as summary.<returned_property_name>?
If my understanding horribly wrong, could I please trouble you for a very basic example for the solution mentioned?
Your understanding is correct. I encourage you to try updating your contact-summary to export a new value and then accessing that value in form properties.