Help needed with async prompt to pass variables between forms/tables

My current issue is one which I thought would be easy to solve:

The household_member form collects data for each ‘person node’ and has all the usual fields, in this case just the first name is important.

A marriage form creates edges between person nodes, and happily passes the uuid of each person associated in the marriage.

My problem is I want to keep the uuid as the edge links, but grab the first name from each person node involved in the marriage for user experience purposes.

All my reading has pointed me to the async custom prompts to achieve this, but I cannot get the first_name data-field to pass from household_member to the marriages form. I have tried for a number of hours, checking all examples in the forum, to no avail.

Attached is the marriage edge creation form, the folder and file structure is as stated in the documentation for async (ie: handlebars and .js files are where they should be.)

Also, when calling the async function, I would prefer not to have the blank prompt fields displayed. Is this possible? Should they even be blank?

Thank you,

marriages.xlsx (20.0 KB)

1 Like

Hi @Kerian! Great question, but I am not entirely sure what you mean when you say the form creates edges or edge links. Edges are not part of the ODK-X infrastructure.

If your goal is to get the uuid and first name into the marriages form, that is very doable, I have done something equivalent in the attached (note this is a slightly older version of ODK-X, but the queries should be similar) where we had done a roster of the household, then in a subsequent form use a query to show potential spouses (see q312_1 Who is the spouse and the roster_spouse query) and then used async_assign right below that to create a string with the spouse line number within the household with a roster_spouse_line query. You could do likewise but for the name rather than the line number. (2.5 KB) quest1_03_0_update.xlsx (53.1 KB)

Thank you,
So the main issue was resolved, had to change the path in customPromptTypes.js, then make sure handlebars file was correct (I accidentally downloaded the git webview version… woops.)

There has been a reoccurring issue which makes development extremely tedious.
Whenever I create a new variable/field, the console spits out that the column doesn’t exist in the table. I directly state it in the model sheet and I’ve checked the definitions.csv, and its all there.
Somehow it seems to resolve itself, I just wonder if there is something I am missing in the declaration of new fields/columns/variables?
I have purged the database when testing, reset grunt, refreshed browser, cleared cache, restarted computer. I can’t seem to figure it out consistently…


I am using subforms to create node and edgelists for processing in R, each spits out their own csv, if that makes sense…

1 Like

Hi @Kerian! So I am not quite sure what you mean when you say when you create a new variable/field, the console spits out that the column doesn’t exist. In general if you are creating a prompt in a form where the tableid=formid, that will just get built in. Otherwise you need to add that prompt to the model of the main form (tableid=formid). If that doesn’t solve if you could grab a screenshot and give a form with the example of a prompt with a problem for this.

That’s what I thought!

Screenshot is of console when clicking into to families form from the main census form.
The families tableid=formid ::

families.xlsx (19.1 KB)

@Kerian :thinking: puzzling! I see you attached the families form; can you attach the main census form? If it is when you are clicking from the main census into the families there may be an issue with the query for the linked_table in the main census form. If you’ve got a tab handy, it’s also always good to check if the columns are appearing in Tables as you’d expect and recording the values you’d expect, that’s often how I figure out where a bug is coming from.

Here we are…
household_census.xlsx (29.0 KB)

The field is created in table view, passes null.

So one possible issue I can spot is that the instance_name, family_id, doesn’t seem to get populated anywhere. It’s in the model but doesn’t get created anywhere I can see in the families form. This isn’t quite what the error message is saying, but is at least a possibility. It also looks like you are storing key variables, e.g. household_id, as string. I can’t remember why we did this, but we tended to store them as text… we may have done that because it worked better. I’d also check whether marriage_uuid is getting recorded correctly since the error seems to be about that. Is marriage_uuid in both the families form and the marriages form?

So, working through your great suggestions, it works(somewhat) on the tablet, but not on the chrome app.
An interesting thing that is happening however, is that when I am querying for child_name(from roster of members table, which works perfectly in the marriages form) and marriage_name (from marriages table) fields from the families form, the date/time field is being passed for both!?
At least this tells me that it is indeed fulfilling the query, and it is visible in the tables app.

Progress at least! Not sure why the chrome app would be angry but it may not do so well with async_assign, I usually test those on the tablet anyways b/c then can check tables as you go. Why the names would show up as dates is a bit of a puzzle. It must be grabbing the wrong variable from the underlying form, although why it would do that is a bit of a mystery. Are the dates actual dates within the form? Or do you mean maybe it is showing the date with the instance name in the linked table? That it does automatically I think – it won’t be recorded in the table, it just shows you in the linked table when last updated.

Screenshot is of async debug within family form. I imagine it is the instance time as you said.

It is odd re chrome, as there were no issues with the original problem at the top of the thread!

Edit: screenshot of debbuging text with variables passed within form.

When you check the marriage_id and first_name fields in the sub-forms this is supposed to pull from, do they look normal? Or have they ended up formatted as dates as well?

They are as they should be.Which only adds to the confusion.

Crazy!!! A few ideas: try changing the type from string to text in the model statement. Also check if anything in your custom prompts or handlebars are doing something date related… might have accidentally overflowed onto the rest of the async_assign code.

Thanks again for all this help!
I’ve tried as suggested, and i can’t see any differences between the working asyc call in marriages to the one in families…
I have pushed the entire project to:

maybe that could give more information…
I hope this is one of those situations where it might be an embarrassingly simple mistake that I am blind to…

@Kerian can you be more specific on exactly what you are trying to accomplish. Async assign might not be needed at all. For example, when calling a Survey form you can pass variables directly to the survey item, you do not need to query them. You need to query/async assign if you are trying to get information from a different database row. However, you can pass your foreign reference key directly into the row from tables.

1 Like

Hello @W_Brunette, thank you for your input.

I am wanting to:
survey households about people living there ( person node with link to household), gather data on the marital status of each member, including people who may not live in the household (marriage edgelist). From the marital status, offspring are then assigned to a family edgelist, creating the data needed for social network analysis (SNA).
This method of creating nodes and edges requires 3 different tables, one for the nodes, and 2 for the edges linking person nodes. This makes processing the data at a later time much easier to manage, in my experience with other SNA projects.
So far the marriage edgelist is working perfectly, and I used async to get the instance uuid and readable marriage_id.
Essentially I am trying to recreate the marriage async call to get the child’s name from the person node, and the marriage_id from the marriage edgelist.

These values are purely for UX purposes, to make it easier on the interviewer to check they have the correct information while filling out the surveys.
Does that clarify my intent enough?
Also it might be worth mentioning that I have based the hierarchy/structure of nodes and edges on the GRAMPS genealogical model.



One suggestion. I noticed is that your async assign query will get results that are not complete yet. Survey temporarily writes intermediate rows into the database as a checkpoint in case an error happens, the UI forces a reload of the webkit, etc. To make sure you only have completed rows with completed information add to your selection column "_savepoint_type = ? and " and to the selection selectionArgs argues column add ‘COMPLETE’ to the list of values to be substituted.

1 Like

After more probing, the async call is not checking the right ‘list’ in my families outcome.
Instead of referencing a id’d list, such as 'firstname_lastname" in my working marriages asyc calls, it references a list containing the data/time data of the instance.

Even when I copy directly the working asyncs from my other form, it does the similar thing.

So my question is, what is this ‘list’ thing the async debug message refers to?

thanks for all this attention!

1 Like

I am afraid I don’t know what list the debug message refers to, although someone else might, but am wondering if it is related to the fieldName you are pulling from? Have you tried removing that part and seeing if it will at least record the uuid without pulling a particular field? I can see that works with the child_id variable, so if you can do the same query and recreate the child_id variable without using the fieldName you will at least have narrowed down where the problem is coming from…