Possibility to query data as input for form

I have found Dynamic Data Attachments — KoBoToolbox documentation, but I am not sure whether the article describes the solution I am looking for.

Currently we use an external csv file with search (appearance) and pulldata (calculations) to access long tables of data (for instance: lists of very many schools). My question is whether the respective questions in the xlsform could pick such data from a database on an external server (instead of from a static csv file on the kobotoolbox server). Background: We will run an online database where the schools lists are maintained in a managed way (after the manual maintenance of csv files turned out to be not clean enough).

Could you explain this further (maybe with an example) so that we could understand it clearly?

…sure, let me try: For example, a select_one question shows a list of schools, taken from the external file facilities_xx.csv (saved under Settings/Media) by the appearance expression: minimal search(‘facilities_xx’,‘contains’, ‘label’, *, ‘flt_geoorg_s’, ${geo_org}), with the geo_org variable containing a geographic selection filter produced by a previous question.

All the information in the csv file is maintained in a database and needs to be manually exported and saved into facilities_xx.csv from time to time.

The question is whether a dynamic transfer into our kobo form is possible. Maybe there is an xlsform expression which doesn’t take the data from a csv file in settings/media, but from a URL? Or maybe it is possible to put a API/URL into settings/media istead of a static file? Or maybe it is possible to save the csv file to settings/media not manually, but through a script in our database?

I am a technical lay, as you can easily see, but I hope that our need is clear and that you experts can translate this into the right technical jargon.

1 Like

…maybe I should have said more precisely: The question is whether a dynamic transfer FROM OUR FACILITY ADMIN DATABASE into our kobo form is possible.

So you mean from a project that has been in a self hosted server to a project that is in a publicly hosted server?

It is not about a (data collection) project on a self-hosted server, it is about a database which allows a smooth administration (adding, changing,) of schools in terms of having their geographic details defined. From there, we can save/export a csv file in the right format and upload it to our KoboCollect data collection project (under settings/media). This is a manual process and prevents that new schools being put on that admin database are available on KoboCollect immediataly (only after someone has done the manual export/upload procedure).

Now, it would be great, if the schools offered in the KoboCollect form would always be exactly the schools on the school admin database, so how can we organize a dynamic link between our server and the kobo project?

Could you what you mean about our server? Do you mean something that is outside the KoBoToolbox system?

…yes, excactly. From our server, we would have available a URL and a security token (or similar, as our developers have full control and can do whatever is technically possible and recommendable) or could push a file to a certain place on the kobo server, if we know how to fulfil the security conditions.

Hi

Any news on this?

To describe the need again in other words: Currently, it is possible to query the data of a kobo project as json string and thus have dynamic access to collected data. What we need is the data flow the other way round: The kobo project would dynamically access data on non-kobo server and make use of them like it is currently able to make use of csv files (pulldata, etc.).

Kind regards
York

Hi @york_rff , can you kindly share with an example of the idea you have proposed?

Hi ta13

Not sure whether I can help. Which idea did I propose? If it is about pulling data – instead from a static csv file – dynamically from an external database, I can’t give you an example, because this thread never produced an answer on how this would be possible.

I interpret the comments/questions from the kobotoolbox team as expression that this is nothing they ever considered (or understand as a need).

Kind regards
York

Hi @york_rff , thanks for your reply. Did you use pulldata function without any calculation? Let’s say, import specific rows value from a csv file, not to match with anything?

pulldata(‘nameofcsv’, ‘columnheadingtopulldatafrom’, ‘columncheckformatchingTEXT’, ‘TEXTtoCheckfor’

I don’t want to use columncheckformatchingTEXT and TEXTtoCheckfor

Please forgive me for not being able to think myself deeply into your specific problem, but maybe the following helps (without being the most elegant solution): you could add a dummy column (like: “datatobepulled”) and put a certain value into the whole column (like: “yes”). In the pulldata call you then could use ‘datatobepulled’ and ‘yes’ on the third and forth position of the pulldata expression.