Basically i would like to know how can i link a project to itself to use, calculate and display data collected on that same form.
For example im building a form to collect user data, and i want to validate if user exists or not to create a new user or modify existing user information.
Is there a way to do this using dynamic data attachment? ( i read the documentation but no examples on this particular case, i only see it connecting a parent to a child project) or is there any different approach for doing this?
This is definitely possible, bearing in mind the small delay needed to update the data thatâs linked. As linking to a form requires that form to have some data submitted, linking a form to itself is a 2-step process. First create the form without any logic referencing itself - below is a super lightweight example.
Then upload at least one submission (even if with dummy data that you delete later), and after itâs uploaded, change the settings to set data sharing as enabled, and then select the form itself from the drop-down in âimport other project dataâ (all in the âconnect projectsâ page).
Now you should be able to add the logic where the form references itself. Below is the updated lightweight example that checks whether 1 or more records already exist with the user-inputted user ID.
For those having issues with this solution, just adding some follow-up clarifications:
Make sure that when you first upload the file, that it does not have any of the following (what I referred to in my earlier solution as âlogic referencing itselfâ):
xml_external type questions
calculations or other fields with instance('<form-name>)/root/data... logic
Then once you have followed the steps in the solution above, you can then re-add these elements to your form
Hi, no worries - can you give me more information as to what youâve tried, and what error messages are shown? Also if youâre able to upload an XLSform that would help
Say I want to check if a phone number has already been used in a survey and immediately flag that as data collection proceeds. Do I have to send the previous survey first so that the contact is in the database or is there a logic to check this even if the previous form is not synched?
The method actually works, itâs just a matter of following the correct sequence in getting the form to work as desired. This sequence wasnât explained to the users who tried using the file, I guess you assumed theyâre already experienced kobotoolbox form users.
Hereâs the sequence:
Create the initial form as explained (i.e. without the linking logic)
Deploy the form
Open the form, fill & submit at least one set of data
Go back to the main form creation area and select data to view & ensure the submitted data exists and has been uploaded & recognized.
This is very important
Once the data is confirmed loaded, select the next menu option - Settings
A list of options menu options are presented on the left.
Select âConnect Projectsâ
In the new window - Enable Data Sharing by pulling the button to the right. Accept the information displayed.
Next Select the data items you want to make visible for sharing
Click the button âSave Changesâ. If not visible click on settings again or on another menu at the top, the Save Changes button will show up.
Steps 4 to 10 are critical and are the steps most people didnât likely go through.
The next steps finalize the connection
Open Settings again,
Select Connect Projects
Scroll down to âImport Data from Other Projectsâ
Click the small drop-down arrow in the box âSelect a different project to import data fromâ
From the list (if you have many listed), pick the name of the current project you want to link back to.
A 2nd box appears underneath repeating same name, overwrite this name with a unique short name without spaces e.g. liveData or returned_data
Click the button import
Select the data items youâll eventually need or refer to
Save Changes and return to forms.
Now download the xls version of your form and include the required link logic statements
Ensure you use the name you assigned in step 16 in all your references to this set of data
e.g.
But May I ask you if that solution works with android app? I did exactly as youâve mentioned, it does work in web version Enketo but not with mobile. Any idea? - Thank you!
Hi - as far as I know it should work in an android app. However, as far as I know, you would have to allow for the initial form to be uploaded from the android app to Kobo server, and then for the android app to sync with the latest changes (which might involve redownloading the form? I would have to double check).
So it would work, allowing for internet and a small delay (hard to estimate without knowing internet connection, but at least 5-10 minutes if not more at a guess?)
Hi, thanks for adding the details! Not at all assuming people were already experienced, just got confused myself as to which steps they had / hadnât followed!
Just adding, for anyone else reading this, that it may be useful to first check out the following documentation for regular dynamic data attachments before trying this advanced version, as it has helpful screenshots and additional information