Link project to itself for using and displaying data collected on same form

Hello all,

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.

Demo Self-reference initial.xlsx (10.5 KB)

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.

Demo Self-reference with logic.xlsx (10.7 KB)

Hope this helps!


@amschel, :clap: :heart: :partying_face:

@amschel You are the best! i will definitely try that on my form logic, Thank you for that amazing explanation and the example provided. Cheers!

1 Like

I tried following the solution step by step but I am unable to implement it. Please help with this. @Kal_Lam @amschel

I am trying to check if the email address and phone number both are new or is already present in the submissions done before.

Hi, at what step are you running into issues? And what is the structure of the form you’re trying to create?

1 Like

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

It doesnot work , Sorry
I’ve been trying for hours. The same steps as you explained.

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

Thank you for your response

I used the same files you shared , and the
same steps . It doesn’t work.

I’m sorry, I don’t think I can give you any more help without knowing more about what is going wrong when you try the solution.

If you can provide more detail, any screenshots, steps taken, error messages the system showed, then I can see if I can work out what’s going wrong.

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?

if the user was already exists, can i pull his data data? like name and surname… ect
if yes… can you give me example pls

Hi amschel,

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:

  1. Create the initial form as explained (i.e. without the linking logic)
  2. Deploy the form
  3. Open the form, fill & submit at least one set of data
  4. 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
  5. Once the data is confirmed loaded, select the next menu option - Settings
  6. A list of options menu options are presented on the left.
  7. Select “Connect Projects”
  8. In the new window - Enable Data Sharing by pulling the button to the right. Accept the information displayed.
  9. Next Select the data items you want to make visible for sharing
  10. 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

  1. Open Settings again,
  2. Select Connect Projects
  3. Scroll down to “Import Data from Other Projects”
  4. Click the small drop-down arrow in the box “Select a different project to import data from”
  5. From the list (if you have many listed), pick the name of the current project you want to link back to.
  6. A 2nd box appears underneath repeating same name, overwrite this name with a unique short name without spaces e.g. liveData or returned_data
  7. Click the button import
  8. Select the data items you’ll eventually need or refer to
  9. Save Changes and return to forms.
  10. Now download the xls version of your form and include the required link logic statements
  11. Ensure you use the name you assigned in step 16 in all your references to this set of data

xml-external liveData

count(instance(‘liveData’)/root/data[user_id = current()/…/user_id]) > 0

Best of luck

1 Like

@Elvis-Great Really appreciate your help!!

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?)

Sorry for the slow reply. Yes, you would have to send the previous survey first for this method to work

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

Hi meerakhanna,

I don’t use the android app, so I wouldn’t know if there’s a difference in the mechanics.

Though, I create all my projects and run them from my Android phone, but it’s basically working online through Google chrome.

Thanks Elvis for response.
I’m still trying to troubleshoot.